content
stringlengths 228
999k
| pred_label
stringclasses 1
value | pred_score
float64 0.5
1
|
---|---|---|
Advent of Code
$year=2016;
--- Day 15: Timing is Everything ---
The halls open into an interior plaza containing a large kinetic sculpture. The sculpture is in a sealed enclosure and seems to involve a set of identical spherical capsules that are carried to the top and allowed to bounce through the maze of spinning pieces.
Part of the sculpture is even interactive! When a button is pressed, a capsule is dropped and tries to fall through slots in a set of rotating discs to finally go through a little hole at the bottom and come out of the sculpture. If any of the slots aren't aligned with the capsule as it passes, the capsule bounces off the disc and soars away. You feel compelled to get one of those capsules.
The discs pause their motion each second and come in different sizes; they seem to each have a fixed number of positions at which they stop. You decide to call the position with the slot 0, and count up for each position it reaches next.
Furthermore, the discs are spaced out so that after you push the button, one second elapses before the first disc is reached, and one second elapses as the capsule passes from one disc to the one below it. So, if you push the button at time=100, then the capsule reaches the top disc at time=101, the second disc at time=102, the third disc at time=103, and so on.
The button will only drop a capsule at an integer time - no fractional seconds allowed.
For example, at time=0, suppose you see the following arrangement:
Disc #1 has 5 positions; at time=0, it is at position 4.
Disc #2 has 2 positions; at time=0, it is at position 1.
If you press the button exactly at time=0, the capsule would start to fall; it would reach the first disc at time=1. Since the first disc was at position 4 at time=0, by time=1 it has ticked one position forward. As a five-position disc, the next position is 0, and the capsule falls through the slot.
Then, at time=2, the capsule reaches the second disc. The second disc has ticked forward two positions at this point: it started at position 1, then continued to position 0, and finally ended up at position 1 again. Because there's only a slot at position 0, the capsule bounces away.
If, however, you wait until time=5 to push the button, then when the capsule reaches each disc, the first disc will have ticked forward 5+1 = 6 times (to position 0), and the second disc will have ticked forward 5+2 = 7 times (also to position 0). In this case, the capsule would fall through the discs and come out of the machine.
However, your situation has more than two discs; you've noted their positions in your puzzle input. What is the first time you can press the button to get a capsule?
To play, please identify yourself via one of these services:
[GitHub] [Google] [Twitter] [Reddit] - [How Does Auth Work?]
(Twitter users: if you have auth problems that claim "There is no request token for this page", please clear your twitter.com cookies and try again.)
|
__label__pos
| 0.941626 |
React - Children Components modifying parents state?
Tell us what’s happening:
I want to make sure I understand whats going on here. I understand that state can flow from Parent Components → Child Components when we render child components with state from the parent passed in to the child via props.
BUT, is the reason that a child component can update its parents state because of the binding of the function this.handleChange to this instance of the parent object?
**Your code so far**
class MyApp extends React.Component {
constructor(props) {
super(props);
this.state = {
inputValue: ''
}
/* Is it because of binding that handleChange is pinned to the MyApp object? */
this.handleChange = this.handleChange.bind(this);
}
handleChange(event) {
this.setState({
inputValue: event.target.value
});
}
render() {
return (
<div>
{ /* Change code below this line */ }
<GetInput
input = {this.state.inputValue}
handleChange = {this.handleChange} />
<RenderInput
input = {this.state.inputValue} />
{ /* Change code above this line */ }
</div>
);
}
};
class GetInput extends React.Component {
constructor(props) {
super(props);
}
render() {
return (
<div>
<h3>Get Input:</h3>
<input
value={this.props.input}
onChange={this.props.handleChange}/>
</div>
);
}
};
class RenderInput extends React.Component {
constructor(props) {
super(props);
}
render() {
return (
<div>
<h3>Input Render:</h3>
<p>{this.props.input}</p>
</div>
);
}
};
**Your browser information:**
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:86.0) Gecko/20100101 Firefox/86.0.
Challenge: Pass a Callback as Props
Link to the challenge:
So this is a concept that was a little tricky for me to wrap my head around when I first learned React. The main thing to understand is, a child element doesn’t know anything about its parent element’s state - it is only aware of its own internal state (if any), and props that are passed to it.
What’s actually happening here is that the parent element MyApp has inputValue as an internal state variable, and it has a handleChange callback defined to change that internal state value. Meanwhile, the child element GetInput is receiving that callback as a prop, so it knows to fire that callback prop whenever the input element has an onChange event. But it’s not really the child element that’s changing the parent’s state - it’s the callback function handleChange that is still only defined in the parent component that is causing the parent’s state to change.
It may be a subtle distinction, but think of the relationship this way. Imagine there’s now a child element that has internal state for a counter, BUT the child element sets the initial state of the counter variable based on a PROP it receives from the parent. Now, from the perspective of the parent element, if I pass down a different counter prop to the child, I can effectively change the initial state of the child, so as a parent component, I have ways of directly affecting the state of the child component.
Now in this original situation, let’s say that the parent component stopped passing down the handleChange callback to the child. At that point, there is absolutely nothing the child component can do to “reach into” the parent to affect its state. Any change that had been happening in the parent state was because the parent wanted the child component to trigger some specific callback in the parent component, so the parent ALLOWS this by passing the function down as a prop.
And as a last aside, the binding of the handleChange function doesn’t have anything to do with the parent/child interaction. It’s just to make it so that we bind this to be the MyApp object, so that this.setState inside the handleChange function doesn’t throw an error.
2 Likes
The idea that what is actually changing the parent’s state IS the child element BUT only because the child is given a callback function as a PROP with access to its parents state makes a lot more sense now.
Also, I now understand why the binding of the function has nothing to really do with the Parent/Child interaction.
Your explanation definitely cleared up some of my misconceptions. I appreciate the very thorough response. I think I need to review the this keyword a little more in JavaScript.
|
__label__pos
| 0.99789 |
Learn how to use the webkitSpeechRecognition API to convert
About the webkitSpeechRecognition API
The Web Speech API, introduced at the end of 2012, allows web developers to provide speech input and text-to-speech output features in a web browser. Typically, these features aren’t available when using standard speech recognition or screen reader software. This API takes care of the privacy of the users. Before allowing the website to access the voice via microphone, the user must explicitly grant permission.
Some important points you need to know :
• It is only available till the date (23.02.2016) only in Google Chrome.
• Local files (file:// protocol) are not allowed, the file needs to be hoster someway in a server (or localhost).
Basic example
The following code will do the most basic support to retrieve what the user says, you can use interim_transcript and final_transcript to show the user the recognized text.
var recognition = new webkitSpeechRecognition();
recognition.continuous = true;
recognition.interimResults = true;
recognition.lang = "en-GB";
recognition.onresult = function(event) {
var interim_transcript = '';
for (var i = event.resultIndex; i < event.results.length; ++i) {
if (event.results[i].isFinal) {
final_transcript += event.results[i][0].transcript;
} else {
interim_transcript += event.results[i][0].transcript;
}
}
console.log(interim_transcript,final_transcript);
};
}
The repository in github of google have a very complete example (with many language codes, prevent errors etc) you can download the demo from the repository here.
Using a library
Artyom.js is a robust wrapper library for the webkitSpeechRecognition API, it allows you to do awesome tricks like voice commands, voice prompt, speech synthesis and many more features. In this case we will be interested in the artyom.newDictation function. This feature will wrap all the previous code in something more simple, first you need to include the library into your project, your html file should look like this :
<!DOCTYPE>
<html>
<head>
<title>Dictation example </title>
<script type="text/javascript" src="path/to/artyom.min.js"></script>
</head>
<body>
<input type="button" onclick="startRecognition();" value="Recognize text" />
<input type="button" onclick="stopRecognition();" value="stop recognition" />
<script>
// we will write the javascript here
</script>
</body>
</html>
If you already linked the artyom library in your document, then your javascript will look something like this:
var settings = {
continuous:true, // Don't stop never because i have https connection
onResult:function(text){
// text = the recognized text
console.log(text);
},
onStart:function(){
console.log("Dictation started by the user");
},
onEnd:function(){
alert("Dictation stopped by the user");
}
};
var UserDictation = artyom.newDictation(settings);
function startRecognition(){
UserDictation.start();
}
function stopRecognition(){
UserDictation.stop();
}
You'll only have to handle the initialization and then , the magic will happen in the onResult property of the settings object. Although artyom makes the things a lot easier, you'll need to think if you really need to use it, if you're beginning with this topic, is recommendable to use the plain code, so you will understand how this api works and if you still interested you can use artyom later.
The potential of this api is really incredible, however is a shame that only google chrome supports it. You can improve all the previous code , for example detect in which browser you can initialize webkitSpeechRecogniton.
Senior Software Engineer at Software Medico. Interested in programming since he was 14 years old, Carlos is a self-taught programmer and founder and author of most of the articles at Our Code World.
Sponsors
|
__label__pos
| 0.968532 |
Generating ticket numbers
I’m trying to generate a number like this for say, a flight number.
I want daily flight numbers to be something like this:
date of flight + (append, not add) 1 (2, 3, 4, 5 etc) eg: 130820211, 130820212, 120820213 etc
In order to do this, I need to search for that date’s flights, get the flight number, but strip away the date part to be left with the last number to add to. Is there a way to do that? I’ve been messing with it for ages but can’t figure it out within the confines of the expression field.
Depending on the format of the incoming string you could use split by I think.
https://manual.bubble.io/core-resources/data/operations-and-comparisons#split-by
push comes to shove you could use “extract with regex” but regex can be a little involved if you’re not already familiar with it.
Hey @tonymoulatsiotis :wave:
I think, if I were you, I would simplify the process. Since you are creating the number yourself, just save the number as two separate fields. One with the full number put together, and the other field as the unique number separate from the number.
For example:
Flight number: 130820211
End Number: 11
Then you can just reference that end number without doing a truncate or regex or anything complicated like that.
Sometimes we make things more difficult than they have to be. Keep it simple if you can.
There are a bunch of ways to do this, this was just one suggestion.
Hope that helps! :blush:
@j805 www.NoCodeMinute.com
For All Your No-Code Education Needs:
1 Like
Hmm, I don’t know what that means.
I may have got around it by doing the following, though I doubt this if very efficient.
Flight has multiple fields, but of note:
Flight Date
Number
Flight Number
Flight Date (date)= takes date from the booking hours and minutes changed to 0
Number (number)= Do a search for flights where Flight Date = booking date hours and minutes changed to 0 sorted by Number, descending :first item + 1 (or basically find the latest flight number on this date then add 1)
Flight Number (TEXT field) = Flight Date formatted as ddmmyyyy :append Number
I ended up with 130820211 like I wanted, though this isn’t really how I’d like to do this…seems very intensive. Since the Flight Number depends on the Number and Flight Date it has to be a second workflow which is annoying. I wish there was a way to do that all in one workflow as there have been a few cases where I have a piece of data that is reliant upon data that hasn’t been created yet but i’d like it to be all in one workflow.
This topic was automatically closed after 70 days. New replies are no longer allowed.
|
__label__pos
| 0.636141 |
Tech Data : How Information Shapes Our Digital Future
Tech Data has become the backbone of innovation and progress. Every interaction, transaction, and operation in the tech world generates data—vast amounts of it. This “tech data” is more than just a collection of numbers and facts; it’s a powerful resource that drives decision-making, enhances user experiences, and fuels the rapid advancement of technology.
From personalized recommendations on streaming platforms to predictive maintenance in manufacturing, tech data is at the core of how businesses operate and grow. It enables companies to understand their customers better, optimize their processes, and stay ahead of the competition. But the importance of tech data goes beyond the corporate world—it’s also reshaping how we live, work, and interact with the world around us.
Tech Data
As we delve deeper into the era of big data, artificial intelligence, and the Internet of Things (IoT), understanding and leveraging tech data is becoming increasingly crucial. This introduction sets the stage for exploring the multifaceted role of tech data, its applications across various industries, and the emerging trends that are defining the future of the digital landscape.
In the rapidly evolving landscape of technology, data is more than just numbers and statistics; it’s the lifeblood of modern innovation. From driving business decisions to shaping consumer experiences, Tech Data plays a crucial role in our digital world. In this blog, we’ll explore the significance of Tech Data, its applications, and how it’s transforming industries across the board.
Understanding Tech Data
Tech data encompasses a wide array of information generated through various digital processes. This includes user behavior analytics, system performance metrics, and even predictive data models. At its core, Tech Data is about understanding patterns, trends, and insights that can be leveraged to optimize processes, enhance user experiences, and drive strategic decision-making.
The Role of Data in Business
For businesses, data is a game-changer. Companies use data analytics to gain a competitive edge, improve operational efficiency, and tailor their offerings to meet customer needs. Key areas where tech data makes a difference include
Tech Data
Customer Insights
Data helps businesses understand customer preferences, behaviors, and feedback. This information allows companies to personalize their services, target specific demographics, and ultimately increase customer satisfaction.
Operational Efficiency
By analyzing system performance data, businesses can identify bottlenecks, streamline processes, and reduce costs. Predictive analytics can also help in anticipating maintenance needs and preventing potential issues before they arise.
Strategic Decision-Making
Data-driven insights support strategic planning and decision-making. Businesses can make informed choices about market expansion, product development, and investment opportunities based on robust data analysis.
Tech Data in the Consumer World
or consumers, tech data often operates behind the scenes, but its impact is profound. For example
Personalized Recommendations
Streaming services, e-commerce platforms, and social media use data to offer personalized recommendations. By analyzing user preferences and behavior, these platforms can suggest content, products, or connections that align with individual interests.
Smart Devices
From smart home systems to wearable technology, data collected from these devices enhances user experiences by providing real-time feedback and automation. For instance, smart thermostats learn user preferences to optimize heating and cooling, improving comfort and energy efficiency.
Challenges and Considerations
While Tech Data offers immense benefits, it also presents challenges. Data privacy and security are major concerns, with the risk of sensitive information being misused or exposed. Companies must prioritize data protection measures and comply with regulations to ensure user trust and safety.
Additionally, the sheer volume of data generated can be overwhelming. Organizations need effective data management strategies and tools to process, analyze, and extract actionable insights without being bogged down by information overload.
The Expanding Horizon of Tech Data
As technology continues to advance, the scope and impact of Tech Data are expanding. Here’s a closer look at some emerging trends and industry-specific applications
Tech Data
Industry-Specific Applications
Healthcare
In healthcare, Tech Data is revolutionizing patient care through electronic health records (EHRs) and wearable health devices. Data analytics enables personalized treatment plans, predictive diagnostics, and improved patient outcomes. For instance, AI algorithms can analyze medical imaging data to detect early signs of diseases such as cancer.
Finance
The financial sector relies heavily on tech data for risk assessment, fraud detection, and market analysis. Algorithms analyze transaction data to identify unusual patterns that may indicate fraudulent activity. Additionally, predictive models help investors make informed decisions by forecasting market trends and economic conditions.
Retail
Retailers use data to optimize inventory management, enhance customer experiences, and drive sales. By analyzing purchasing patterns and customer feedback, businesses can tailor promotions and product recommendations, ultimately boosting customer loyalty and revenue.
Emerging Trends
Artificial Intelligence and Machine Learning: AI and ML are transforming how data is analyzed and utilized. These technologies enable more sophisticated data processing, allowing for real-time insights and automation. For example, chatbots powered by AI can handle customer inquiries and provide personalized support based on data-driven interactions.
Big Data and Analytics
The rise of big data has led to more advanced analytics tools that can handle vast amounts of information. Big data platforms integrate data from various sources, providing a comprehensive view of trends and patterns that were previously difficult to uncover.
Edge Computing
Edge computing involves processing data closer to its source rather than relying on centralized data centers. This approach reduces latency and improves real-time data processing, which is crucial for applications such as autonomous vehicles and smart cities.
Best Practices for Data Management
Data Quality
Ensuring data accuracy and consistency is essential for reliable analysis. Implementing data validation processes and regular audits can help maintain high data quality and prevent errors.
Data Privacy and Security
Protecting data from unauthorized access and breaches is critical. Organizations should adopt robust security measures, including encryption, access controls, and regular security assessments, to safeguard sensitive information.
Data Integration
Integrating data from diverse sources into a unified system allows for a more comprehensive analysis. Employing data integration tools and strategies helps consolidate information and provides a holistic view of operations.
Ethical Data Use
Ethical considerations are crucial when handling tech data. Organizations should be transparent about data collection practices, obtain informed consent from users, and avoid using data in ways that could harm individuals or communities.
The Role of Data Governance
Effective data governance ensures that data management practices align with organizational goals and regulatory requirements. It involves defining data ownership, establishing policies for data usage, and ensuring compliance with data protection laws. A strong data governance framework supports data integrity and helps organizations navigate the complexities of data management.
The Impact of Data Democratization
Data democratization refers to making data accessible to a broader range of users within an organization. By providing tools and training to non-technical staff, organizations can empower employees to leverage data for decision-making and innovation. This approach fosters a data-driven culture and enhances overall business agility.
The Societal and Cultural Impact of Tech Data
Tech Data
Tech data isn’t just transforming industries; it’s also reshaping society and culture in profound ways. Here’s a closer look at some of these impacts
Changing Consumer Expectations
The availability of personalized data-driven experiences has set new standards for consumer expectations. People now expect seamless, personalized interactions with brands, driven by data insights. Whether it’s customized content recommendations on streaming platforms or tailored marketing messages, consumers are increasingly accustomed to experiences that cater to their specific preferences.
Influencing Public Opinion
Tech Data plays a significant role in shaping public opinion through social media and online platforms. Social media algorithms analyze user data to curate content feeds, which can influence perceptions and opinions. This phenomenon has implications for everything from political campaigns to social movements, highlighting the need for responsible data practices and transparency.
Shaping Digital Identity
As individuals interact with digital platforms, they generate data that contributes to their digital identity. This digital footprint can impact various aspects of life, including job prospects and online reputation. Understanding how personal data is used and managed is crucial for individuals in protecting their digital identities and privacy.
Enhancing Education
Education, data-driven insights are transforming teaching and learning experiences. Educational platforms use data to track student progress, personalize learning paths, and identify areas where additional support is needed. This data-driven approach helps educators better address individual student needs and improve educational outcomes.
The Role of Data in Innovation
Tech data is a catalyst for innovation, driving advancements across various fields. Here’s how data is fueling innovation
Accelerating Research and Development
Data accelerates R&D processes by providing insights that inform experimentation and iteration. In fields such as pharmaceuticals and materials science, data analytics helps researchers identify promising compounds or materials faster, leading to quicker discoveries and advancements.
Enabling Smart Technologies
Smart technologies, including smart cities, smart homes, and connected devices, rely on data to function effectively. Data from sensors and IoT devices enables real-time monitoring, automation, and optimization of systems, leading to more efficient and intelligent technology solutions.
Facilitating Predictive Analytics
Predictive analytics uses historical data to forecast future trends and behaviors. This capability is invaluable across industries, from predicting equipment failures in manufacturing to anticipating customer needs in retail. By leveraging predictive models, organizations can proactively address challenges and seize opportunities.
Strategies for Leveraging Data Effectively
To maximize the benefits of tech data, organizations should adopt strategic approaches for data utilization
Develop a Data Strategy
A well-defined data strategy outlines how data will be collected, managed, analyzed, and used to achieve business objectives. It should align with organizational goals and include clear guidelines for data governance, privacy, and security.
Invest in Data Infrastructure
Robust data infrastructure is essential for handling and processing large volumes of data. Investing in scalable data storage solutions, advanced analytics platforms, and data integration tools ensures that organizations can effectively manage and leverage their data assets.
Foster a Data-Driven Culture
Encouraging a data-driven culture involves promoting data literacy across the organization and empowering employees to make data-informed decisions. Training programs and data visualization tools can help staff understand and utilize data effectively in their roles.
Collaborate and Share Data
Collaborating with external partners and sharing data can lead to new insights and opportunities. Data sharing agreements and partnerships with research institutions or industry peers can enhance data quality, broaden perspectives, and drive innovation.
Continuously Evaluate and Adapt
The landscape of tech data is constantly evolving, so organizations must continuously evaluate their data practices and adapt to emerging trends and technologies. Regularly reviewing data strategies and incorporating feedback helps ensure that data initiatives remain relevant and effective.
The Future of Tech Data
Tech Data
As technology continues to advance, the role of data will only become more prominent. Emerging technologies like artificial intelligence, machine learning, and the Internet of Things (IoT) will drive new innovations and applications for Tech Data. Businesses and consumers alike will benefit from more accurate predictions, personalized experiences, and smarter systems.
Tech Data is a powerful tool that shapes our digital world in myriad ways. From enhancing business operations to personalizing consumer experiences, the insights derived from data are crucial for progress and innovation. As we move forward, harnessing the power of Tech Data responsibly will be key to unlocking its full potential and driving a better, more connected future.
FAQ
What is tech data?
Tech data refers to information generated and collected through digital processes, including user behavior, system performance, and other technical metrics. It encompasses a broad range of data types used to analyze and improve technology-related activities and systems.
Why is tech data important?
Tech data is crucial because it provides insights that drive decision-making, optimize operations, and enhance user experiences. It helps businesses understand customer behavior, improve product performance, and identify opportunities for innovation.
How is tech data collected?
Tech data can be collected through various methods, including
User Interactions: Tracking user actions on websites, apps, and other digital platforms.
System Monitoring: Gathering performance metrics from hardware and software systems.
Sensors and IoT Devices: Collecting data from connected devices and sensors.
Surveys and Feedback Forms: Obtaining direct input from users or customers.
What are some common applications of tech data?
Tech data is used in numerous applications, such as
Personalization: Tailoring content, products, and services to individual preferences.
Predictive Analytics: Forecasting future trends and behaviors based on historical data.
Operational Efficiency: Streamlining processes and identifying areas for improvement.
Fraud Detection: Identifying unusual patterns that may indicate fraudulent activity.
What are the challenges associated with managing tech data?
Key challenges include
Data Privacy: Ensuring that sensitive information is protected and handled in compliance with regulations.
Data Security: Preventing unauthorized access and breaches.
Data Quality: Maintaining accuracy and consistency in collected data.
Data Overload: Managing and analyzing large volumes of data effectively.
conclusion
Tech data is more than just a resource; it’s a transformative force that drives innovation, shapes decision-making, and enhances user experiences. As we continue to generate and analyze vast amounts of data, its influence will only grow, impacting industries, societies, and cultures worldwide.
For businesses, effectively leveraging tech data means gaining a competitive edge, optimizing operations, and delivering personalized experiences that meet ever-evolving consumer expectations. However, with great power comes great responsibility. The challenges of data privacy, security, and ethical use must be addressed to ensure that the benefits of tech data are realized without compromising trust or integrity.
Tech data is not just a tool—it’s the foundation upon which the future of technology and society is being built. By understanding its power and responsibly managing its use, we can pave the way for a future where data-driven insights lead to smarter decisions, greater innovation, and a better quality of life for all.
Leave a Comment
|
__label__pos
| 0.98722 |
GroupDocsGists
10/24/2017 - 1:52 PM
PopulateData.cs
// For complete examples and data files, please go to https://github.com/groupdocsassembly/GroupDocs_Assembly_NET
/// <summary>
/// This function initializes/populates the data.
/// Initialize Customer information, product information and order information
/// </summary>
/// <returns>Returns customer's complete information</returns>
public static IEnumerable<BusinessObjects.Customer> PopulateData()
{
BusinessObjects.Customer customer = new BusinessObjects.Customer { CustomerName = "Atir Tahir", CustomerContactNumber = "+9211874", ShippingAddress = "Flat # 1, Kiyani Plaza ISB", Barcode = "123456789qwertyu0025" };
customer.Order = new BusinessObjects.Order[]
{
new BusinessObjects.Order { Product = new BusinessObjects.Product { ProductName ="Lumia 525" }, Customer = customer, Price= 170, ProductQuantity = 5, OrderDate = new DateTime(2015, 1, 1) }
};
yield return customer; //yield return statement will return one data at a time
customer = new BusinessObjects.Customer { CustomerName = "Usman Aziz", CustomerContactNumber = "+458789", ShippingAddress = "Quette House, Park Road, ISB", Barcode = "123456789qwertyu0025" };
customer.Order = new BusinessObjects.Order[]
{
new BusinessObjects.Order { Product = new BusinessObjects.Product { ProductName = "Lenovo G50" }, Customer = customer, Price = 480, ProductQuantity = 2, OrderDate = new DateTime(2015, 2, 1) },
new BusinessObjects.Order { Product = new BusinessObjects.Product { ProductName = "Pavilion G6"}, Customer = customer, Price = 400, ProductQuantity = 1, OrderDate = new DateTime(2015, 10, 1) },
new BusinessObjects.Order { Product = new BusinessObjects.Product { ProductName = "Nexus 5"}, Customer = customer, Price = 320, ProductQuantity = 3, OrderDate = new DateTime(2015, 6, 1) }
};
yield return customer; //yield return statement will return one data at a time
}
|
__label__pos
| 0.985542 |
Introduction to Latency on Computer Networks
About Latency
Laptop computer streaming data.
John Lamb/Digital Vision/Getty Images
What is Network Latency?
Bandwidth is just one element of what a person perceives as the speed of a network. Latency is another element that contributes to network speed. The term latency refers to any of several kinds of delays typically incurred in processing of network data. A so-called low latency network connection is one that experiences small delay times, while a high latency connection suffers from long delays.
Besides propagation delays, latency also may also involve transmission delays (properties of the physical medium) and processing delays (such as passing through proxy servers or making network hops on the Internet).
Latency vs. Throughput
Although the theoretical peak bandwidth of a network connection is fixed according to the technology used, the actual amount of data that flows over a connection (called throughput) varies over time and is affected by higher and lower latencies. Excessive latency creates bottlenecks that prevent data from filling the network pipe, thus decreasing throughput and limiting the maximum effective bandwidth of a connection. The impact of latency on network throughput can be temporary (lasting a few seconds) or persistent (constant) depending on the source of the delays.
Latency of Broadband Internet Services
On DSL or cable Internet connections, latencies of less than 100 milliseconds (ms) are typical and less than 25 ms are often possible.
Satellite Internet connections, on the other hand, typical latencies can be 500 ms or higher. An Internet service rated at 20 Mbps can perform noticeably worse than a service rated at 5 Mbps if it is running with high latency.
Satellite Internet service illustrates the difference between latency and bandwidth on computer networks.
Satellite Internet connections possess both high bandwidth and high latency. When loading a Web page, for example, most satellite users can observe a noticeable delay from the time they enter a Web address to the time the page begins loading. This high latency is due primarily to propagation delay as the request message travels at the speed of light to the distant satellite station and back to the home network. Once the messages arrive on Earth, however, the page loads quickly like on other high-bandwidth Internet connections (such as DSL or cable Internet).
Measuring Network Latency
Network tools like ping tests and traceroute measure latency by determining the time it takes a given network packet to travel from source to destination and back, the so-called round-trip time. Round-trip time is not the only way to measure latency, but it is the most common.
Summary
Two key elements of network performance are bandwidth and latency. The average person is more familiar with the concept of bandwidth as that is the one advertised by manufacturers of network equipment. However, latency matters equally to the end user experience as the behavior of satellite Internet connections illustrates. Quality of Service (QoS) features of home and business networks are designed to help manage both bandwidth and latency together to provide more consistent performance.
|
__label__pos
| 0.953722 |
📣 Catch us at GraphQLConf 2024 • September 10-12 • San Francisco • Know more →
Skip to main content
Command Line Reference
The Tailcall CLI (Command Line Interface) allows developers to manage and optimize GraphQL configurations directly from the command line.
check
The check command validates a composition spec. Notably, this command can detect potential N+1 issues. To use the check command, follow this format:
tailcall check [OPTIONS] <FILE_PATHS>...
The check command offers options that control settings such as the display of the generated schema, n + 1 issues etc.
--n-plus-one-queries
This flag triggers the detection of N+1 issues.
• Type: Boolean
• Default: false
tailcall check --n-plus-one-queries <FILE_PATHS> ...
--schema
This option enables the display of the schema of the composition spec.
• Type: Boolean
• Default: false
tailcall check --schema <file1> <file2> ... <fileN>
The check command allows for files. Specify each file path, separated by a space, after the options.
Example:
tailcall check --schema ./path/to/file1.graphql ./path/to/file2.graphql
--format
This is an optional command which allows changing the format of the input file. It accepts gql or graphql,yml or yaml, json .
tailcall check ./path/to/file1.graphql ./path/to/file2.graphql --format json
start
The start command launches the GraphQL Server for the specific configuration.
To start the server, use the following command:
tailcall start <file1> <file2> ... <fileN> <http_path1> <http_path2> .. <http_pathN>
The start command allows for files and supports loading configurations over HTTP. You can mix file system paths with HTTP paths. Specify each path, separated by a space, after the options.
Example:
tailcall start ./path/to/file1.graphql ./path/to/file2.graphql http://example.com/file2.graphql
init
The init command bootstraps a new Tailcall project. It creates the necessary GraphQL schema files in the provided file path.
tailcall init <file_path>
This command prompts for file creation and configuration, creating the following files:
File NameDescription
.tailcallrc.schema.jsonProvides autocomplete in your editor when the configuration is written in json or yml format.
.graphqlrc.ymlAn IDE configuration that references your GraphQL configuration (if it's in .graphql format) and the following .tailcallrc.graphql.
.tailcallrc.graphqlContains Tailcall specific auto-completions for .graphql format.
gen
The gen command in the Tailcall CLI is designed to generate GraphQL configurations from various sources, such as protobuf files and REST endpoints.
usage:
tailcall gen path_to_configuration_file.json
To generate a Tailcall GraphQL configuration, provide a configuration file to the gen command like done above. This configuration file should be in JSON or YAML format, as illustrated in the example below:
{
"llm": {
"model": "gemini-1.5-flash-latest",
"secret": "API_KEY"
},
"inputs": [
{
"curl": {
"src": "https://jsonplaceholder.typicode.com/posts/1",
"fieldName": "post",
"headers": {
"Content-Type": "application/json",
"Accept": "application/json",
"Authorization": "Bearer {{.env.AUTH_TOKEN}}"
}
}
},
{
"curl": {
"src": "https://jsonplaceholder.typicode.com/posts",
"method": "POST",
"body": {
"title": "Tailcall - Modern GraphQL Runtime",
"body": "Tailcall - Modern GraphQL Runtime",
"userId": 1
},
"headers": {
"Content-Type": "application/json",
"Accept": "application/json"
},
"isMutation": true,
"fieldName": "createPost"
}
},
{
"proto": {
"src": "./news.proto"
}
}
],
"output": {
"path": "./output.graphql",
"format": "graphQL"
},
"schema": {
"query": "Query",
"mutation": "Mutation"
},
"preset": {
"mergeType": 1,
"consolidateURL": 0.5,
"treeShake": true,
"unwrapSingleFieldTypes": true,
"inferTypeNames": true
}
}
Inputs
The inputs section specifies the sources from which the GraphQL configuration should be generated. Each source can be either a REST endpoint or a protobuf file.
1. REST: When defining REST endpoints, the configuration should include the following properties.
1. src (Required): The URL of the REST endpoint. In this example, it points to a specific post on jsonplaceholder.typicode.com.
2. fieldName (Required): A unique name that should be used as the field name, which is then used in the operation type. In the example below, it's set to post.
important
Ensure that each field name is unique across the entire configuration to prevent overwriting previous definitions.
3. headers (Optional): Users can specify the required headers to make the HTTP request in the headers section.
info
Ensure that secrets are not stored directly in the configuration file. Instead, use templates to securely reference secrets from environment variables. For example, see the following configuration where AUTH_TOKEN is referenced from the environment like {{.env.AUTH_TOKEN}}.
4. body (Optional): This property allows you to specify the request body for methods like POST or PUT. If the endpoint requires a payload, include it here.
5. method (Optional): Specify the HTTP method for the request (e.g. GET, POST, PUT, DEL). If not provided, the default method is GET.
6. isMutation (Optional): This flag indicates whether the request should be treated as a GraphQL Mutation. Set isMutation to true to configure the request as a Mutation. If not specified or set to false, the request will be treated as a Query by default.
2. Query Operation: To define a GraphQL Query, either omit the isMutation property or set it to false. By default, if isMutation is not provided, the request will be configured as a Query.
sample input example for generating Query type
sample input example for generating Query type
{
"curl": {
"src": "https://jsonplaceholder.typicode.com/posts/1",
"fieldName": "post",
"headers": {
"Authorization": "Bearer {{.env.AUTH_TOKEN}}"
}
}
}
For the above input configuration, the following field will be generated in the operation type:
Generated Configuration
Generated Configuration
type Query {
# field name is taken from the above JSON config
post(p1: Int!): Post @http(path: "/posts/{{arg.p1}}")
}
3. Mutation Operation: To define a GraphQL Mutation, set isMutation to true and provide the necessary request body, method, isMutation and headers.
sample input example for generating Mutation type
sample input example for generating Mutation type
{
"curl": {
"src": "https://jsonplaceholder.typicode.com/posts",
"method": "POST",
"body": {
"title": "Tailcall - Modern GraphQL Runtime",
"body": "Tailcall - Modern GraphQL Runtime",
"userId": 1
},
"headers": {
"Content-Type": "application/json",
"Accept": "application/json"
},
"isMutation": true,
"fieldName": "createPost"
}
}
For the above input configuration, the following field will be generated in the operation type:
Generated Configuration
Generated Configuration
input PostInput {
title: String
body: String
userId: ID
}
type Mutation {
# field name is taken from the above JSON config
createPost(createPostInput: PostInput!): Post
@http(path: "/posts/{{arg.p1}}", method: "POST")
}
4. Proto: For protobuf files, specify the path to the proto file (src).
{
"proto": {
"src": "./path/to/file.proto"
}
}
Output
The output section specifies the path and format for the generated GraphQL configuration.
• path: The file path where the output will be saved.
• format: The format of the output file. Supported formats are json, yml, and graphQL.
tip
You can also change the format of the configuration later using the check command.
Preset
The config generator provides a set of tuning parameters that can make the generated configurations more readable by reducing duplication. This can be configured using the preset section.
Presets with default values
Presets with default values
{
"preset": {
"mergeType": 1,
"consolidateURL": 0.5,
"treeShake": true,
"unwrapSingleFieldTypes": true,
"inferTypeNames": true
}
}
1. mergeType: This setting merges types in the configuration that satisfy the threshold criteria. It takes a threshold value between 0.0 and 1.0 to determine if two types should be merged or not. The default is 1.0.
For example, the following types T1 and T2 are exactly similar, and with a threshold value of 1.0, they can be merged into a single type called M1:
Merging type T1 and T2 into M1
Merging type T1 and T2 into M1
# BEFORE
type T1 {
id: ID
firstName: String
lastName: String
}
type T2 {
id: ID
firstName: String
lastName: String
}
# AFTER: T1 and T2 are merged into M1.
type M1 {
id: ID
firstName: String
lastName: String
}
2. consolidateURL: The setting identifies the most common base URL among multiple REST endpoints and uses this URL in the upstream directive. It takes a threshold value between 0.0 and 1.0 to determine the most common endpoint. The default is 0.5.
For example, if the Query type has three base URLs, using the consolidateURL setting with a 0.5 threshold will pick the base URL that is used in more than 50% of the http directives, http://jsonplaceholder.typicode.com, and add it to the upstream, cleaning the base URLs from the Query type.
schema
@server(hostname: "0.0.0.0", port: 8000)
@upstream(httpCache: 42) {
query: Query
}
type Query {
post(id: Int!): Post
@http(
baseURL: "http://jsonplaceholder.typicode.com"
path: "/posts/{{.args.id}}"
)
posts: [Post]
@http(
baseURL: "http://jsonplaceholder.typicode.com"
path: "/posts"
)
user(id: Int!): User
@http(
baseURL: "http://jsonplaceholder.typicode.com"
path: "/users/{{.args.id}}"
)
users: [User]
@http(
baseURL: "http://jsonplaceholder-1.typicode.com"
path: "/users"
)
}
After enabling the consolidateURL setting:
schema
@server(hostname: "0.0.0.0", port: 8000)
@upstream(
baseURL: "http://jsonplaceholder.typicode.com"
httpCache: 42
) {
query: Query
}
type Query {
post(id: Int!): Post @http(path: "/posts/{{.args.id}}")
posts: [Post] @http(path: "/posts")
user(id: Int!): User @http(path: "/users/{{.args.id}}")
users: [User]
@http(
baseURL: "http://jsonplaceholder-1.typicode.com"
path: "/users"
)
}
3. treeShake: This setting removes unused types from the configuration. When enabled, any type that is defined in the configuration but not referenced anywhere else (e.g., as a field type, union member, or interface implementation) will be removed. This helps to keep the configuration clean and free from unnecessary definitions.
Before applying treeShake, the configuration might look like this.
Before applying treeShake, the configuration might look like this.
type Query {
foo: Foo
}
type Foo {
bar: Bar
}
# Type not used anywhere else
type UnusedType {
baz: String
}
type Bar {
a: Int
}
After enabling treeShake, the UnusedType will be removed.
After enabling treeShake, the UnusedType will be removed.
type Query {
foo: Foo
}
type Foo {
bar: Bar
}
type Bar {
a: Int
}
4. unwrapSingleFieldTypes: This setting instructs Tailcall to flatten out types with single field.
Before applying the setting
Before applying the setting
type Query {
foo: Foo
}
# Type with only one field
type Foo {
bar: Bar
}
# Type with only one field
type Bar {
a: Int
}
After applying setting
After applying setting
type Query {
foo: Int
}
This helps in flattening out types into single field.
5. inferTypeNames: This setting enables the automatic inference of type names based on their schema and it's usage. For it to work reliably it depends on an external secure AI agent.
Before enabling inferTypeNames setting
Before enabling inferTypeNames setting
type T1 {
id: ID
name: String
email: String
post: [T2]
}
type T2 {
id: ID
title: String
body: String
}
type Query {
users: [T1] @http(path: "/users")
}
• Type T1: T1 is used as the output type for the user field in the Query type. We recognize that T1 is associated with users in the users field of Query. Therefore, it infers that T1 should be named User to indicate that it represents user data.
• Type T2: T2 is used as the output type for the post field within T1. We recognize that T2 is associated with posts in the post field of User. Therefore, it infers that T2 should be named Post to indicate that it represents post data.
After enabling inferTypeNames setting
After enabling inferTypeNames setting
type User {
id: ID
name: String
email: String
post: [Post]
}
type Post {
id: ID
title: String
body: String
}
type Query {
user: User @http(path: "/users")
}
By leveraging field names to derive type names, the schema becomes more intuitive and aligned with the data it represents, enhancing overall readability and understanding.
LLM
Tailcall leverages LLM to improve the quality of configuration files by suggesting better names for types, fields, and more. The llm section in the configuration allows you to specify the LLM model and secret (API key) that will be used for generating the configuration.
Example:
• Using Gemini. Set TAILCALL_LLM_API_KEY to your Gemini API key.
"llm": {
"model": "gemini-1.5-flash-latest",
"secret": "{{.env.TAILCALL_LLM_API_KEY}}"
}
• Using Ollama. Don't need secret.
"llm": {
"model": "gemma2",
}
important
Ensure that secrets are not stored directly in the configuration file. Instead, use templates to securely reference secrets from environment variables. For example, you can write secret as {{.env.TAILCALL_SECRET}}, where TAILCALL_SECRET is referenced from the running environment.
|
__label__pos
| 0.994129 |
weevely3后门分析
作者: 分类: 代码审计,CTF 时间: 2016-09-22 浏览: 10432 评论: 2条评论
去上交打国赛的时候web里面的后门
123.png
在15到16行间插入一个echo $L; 运行得到
234.png
整理一下
阅读全文»
代码审计学习(五)三个白帽绕过waf注入
作者: 分类: 代码审计 时间: 2016-04-25 浏览: 69128 评论: 6条评论
一直觉得自己sql注入还不错 直到遇到雨牛这个题 Orz
我是雨牛的脑残粉 :)
按照惯例 先上代码 如果看到奇怪的echo,只是我的调试代码~
0x01 热身
read.php~
<?php
$file=isset($_GET['file'])?$_GET['file']:'';
if(empty($file)){
exit('The file parameter is empty,Please input it');
}
if( preg_match('/.php/i',$file) && is_file($file) ){
die("The parameter is not allow contain php!"); //
}
if( preg_match('/admin_index|\.\/|admin_xx_modify/i',$file) ){
die('Error String!');
}
$realfile = 'aaaaaa/../'.$file; //prevent to use agreement
if(!@readfile($realfile)){
exit('File not exists');
}
?>
看到第一个if 是&&一个is_file 那么只要后面为假就可以了
阅读全文»
代码审计学习(四) 三个白帽xor挑战
作者: 分类: 代码审计 时间: 2016-04-18 浏览: 9605 评论: 4条评论
很难找到一个密码学的实例,就拿上一期的xor挑战来讲咯
和基友@overlord一起搞了俩天才弄出来,星期四下午刚学的知识,当天晚上就用上了,也是很神奇~
先上代码吧
<?php
include("config.php");
header("Content-type: text/html; charset=utf-8");
function authcode($string, $operation = 'DECODE', $key = '', $expiry = 0) {
$ckey_length = 8;
$key = md5($key ? $key : '');
$keya = md5(substr($key, 0, 16));
$keyb = md5(substr($key, 16, 16));
$keyc = $ckey_length ? ($operation == 'DECODE' ? substr($string, 0, $ckey_length): substr(md5(microtime()), -$ckey_length)) : '';
$cryptkey = hash('sha256', $keya.md5($keya.$keyc));
$string = $operation == 'DECODE' ? base64_decode(substr($string, $ckey_length)) : sprintf('%010d', $expiry ? $expiry + time() : 0).md5($keyb.$string).$string;
$string_length = strlen($string);
$result = '';
for ($i=0; $i<$string_length; $i++){
$result .= $string[$i] ^ $cryptkey[$i % 64];
}
if($operation == 'DECODE') {
if((substr($result, 0, 10) == 0 || substr($result, 0, 10) - time() > 0) && substr($result, 10, 32) == md5($keyb.substr($result, 42))) {
return substr($result, 42);
} else {
return '';
}
} else {
return $keyc.str_replace('=', '', base64_encode($result));
}
}
if (isset($_GET['showSource'])){
show_source(__FILE__);
die;
}
session_start();
if ($_COOKIE['auth']){
list($user, $password) = explode("\t", authcode($_COOKIE['auth'], 'DECODE', $secret_key));
if ($user !='' && $password != ''){
$sql = "select uid, username, password from users where username='$user'";
$result = mysql_query($sql);
if ($result){
$row = @mysql_fetch_array($result);
if ($row['password']===md5($password)){
$_SESSION['uid'] = $row['uid'];
echo "<div style=\"text-align:left\"><h4>Welcome ".$row['username'].". My lord!</h4></div><br/>";
}
}
}
}
if (!$_SESSION['uid']) {
echo "<div style=\"text-align:left\"><h4>Decrypt me!: ".authcode(base64_encode($msg), 'ENCODE', $secret_key)."</h4></div><br/>";
}else{
echo $msg;
}
?>
<!--<a href="/?showSource">view source</a>-->
阅读全文»
代码审计学习(三)CI框架 startbbs
作者: 分类: 代码审计 时间: 2016-04-03 浏览: 8603 评论: 3条评论
更新有点迟了 CI框架看的有点晕(其实是玩了几天游戏,哈哈哈)
startbbs v1.2.3
如果有不对的地方请大牛指正
0x00 背景
先说说框架,第一次看框架,完全懵逼状态。
主要要弄懂怎么路由
列如 http://192.168.131.136/startbbs/index.php/topic/show/1
会找到应用目录(app)控制器目录(controllers)下的topic.php的show方法参数为1
如图
uri演示图.png
阅读全文»
代码审计学习(二)ourphp
作者: 分类: 代码审计 时间: 2016-03-17 浏览: 5432 评论: 1条评论
看了1天 还算有点结果。
这次是ourphp,源码链接
0x01 重置所有用户口令
先看通用的函数 /function/ourphp_function.class.php
dowithsql.png
阅读全文»
|
__label__pos
| 0.852709 |
Congruent or Congruence
Definition: congruent means that objects have the same shape. It does not mean that they are 'equal', exactly.
People often confuse this word with 'equal,' but there is a small difference in the way that these two words should be used.
Equal should be used to relate the lengths or measurements of two sides, angles or parts of shapes.
Examples of 'congruent'
Side AB is congruent to BC
$$ \angle A $$ is congruent $$ \to \angle B $$
Examples of 'equal'
The length of side AB is equal to the length of side BC
the measure of $$ \angle A $$ equals the measure of $$ \angle B $$
Ultimate Math Solver (Free)
Free Algebra Solver ... type anything in there!
|
__label__pos
| 0.76961 |
From Fedora Project Wiki
m (Preparation: typo "critical patch" -> "critical path")
(Simple (required) categorization)
Line 29: Line 29:
=== Simple (required) categorization ===
=== Simple (required) categorization ===
Add each test case for your package to the category named ''Category:Package_(packagename)_test_cases'', where (packagename) is the name of the package - use the .src.rpm name, not binary package names. For our yum example, the category would be named ''Category:Package_yum_test_cases''. Make this category a sub-category of [[:Category:Test_Cases]], and use the feature that lets you adjust the sorting order so it appears under the appropriate letter. For our yum example, we would add <nowiki>[[Category:Test_Cases|Y]]</nowiki> to the ''Category:Package_yum_test_cases'' page, which would make it appear under 'Y' in the [[:Category:Test_Cases]] page, not under 'P'. If you identified any critical path functions, add the test case(s) for those function(s) to the category named [[:Category:Critical_path_test_cases]].
+
Add each test case for your package to the category named ''Category:Package_(packagename)_test_cases'', where (packagename) is the name of the package. '''Use the .src.rpm name, not binary package names'''. For our yum example, the category would be named ''Category:Package_yum_test_cases''. Make this category a sub-category of [[:Category:Test_Cases]], and use the feature that lets you adjust the sorting order so it appears under the appropriate letter. For our yum example, we would add <nowiki>[[Category:Test_Cases|Y]]</nowiki> to the ''Category:Package_yum_test_cases'' page, which would make it appear under 'Y' in the [[:Category:Test_Cases]] page, not under 'P'. If you identified any critical path functions, add the test case(s) for those function(s) to the category named [[:Category:Critical_path_test_cases]].
For our yum example, consider two test cases:
For our yum example, consider two test cases:
Latest revision as of 04:59, 8 June 2011
This SOP describes the process for creating a test plan for a specific package. Following the procedure outlined on this page is important as it ensures we use a similar process for testing all packages in Fedora, and makes it simpler to integrate these tests into the update release process.
Background
A test plan, for Fedora, is a co-ordinated set of test cases that, together, test the functionality of some particular piece of software, or process.
Preparation
In most cases, the best way to go about creating a test plan for a particular package is to consider the tasks or functions the package is capable of performing. For instance, if the package you wished to create a test plan for was yum, you might identify the following functions:
• install a package
• remove a package
• provide information on a package
• search for a package
• update the system
• set up a repository
• disable a repository
Identify, if any, some or all of the functions that constitute part of the Fedora critical path. For our yum example, update the system would be a critical path function. You may also want to split the functions into 'core' and 'extended' groups: those that are functions so basic the package would be considered severely broken if they were to fail, and those that are less important. Of course, if you are creating a test plan for a very complex package, it may be impractical to create test cases for every possible function, or even to identify them all. In this case simply concentrate on the most vital functions first of all, particularly Fedora critical path functions. Even if you can only create one test case, or a very small number, this is better than having none at all!
Test case creation
Once you have identified the functions you wish to create test cases for, create a test case for each function, according to the SOP for creating test cases.
Categorization
To link the cases together and ensure they can easily be found both manually and automatically (for the potential use of tools such as Bodhi, Fedora Easy Karma or others), use categories. You should always create or use the appropriate category whenever creating a package-specific test case, no matter what the immediate purpose of the test case is, or if there is only one test case: the category is still necessary in this case to help people locate the test case.
Simple (required) categorization
Add each test case for your package to the category named Category:Package_(packagename)_test_cases, where (packagename) is the name of the package. Use the .src.rpm name, not binary package names. For our yum example, the category would be named Category:Package_yum_test_cases. Make this category a sub-category of Category:Test_Cases, and use the feature that lets you adjust the sorting order so it appears under the appropriate letter. For our yum example, we would add [[Category:Test_Cases|Y]] to the Category:Package_yum_test_cases page, which would make it appear under 'Y' in the Category:Test_Cases page, not under 'P'. If you identified any critical path functions, add the test case(s) for those function(s) to the category named Category:Critical_path_test_cases.
For our yum example, consider two test cases:
• QA:Testcase_yum_upgrade - to test upgrading the system
• QA:Testcase_yum_history - to test yum's history function
Both must be in the category Category:Package_yum_test_cases, and that category should be a sub-category of Category:Test_Cases. However, QA:Testcase_yum_upgrade must also be in the category Category:Critical_path_test_cases.
Advanced (optional) categorization
If you want to split the test cases into groups, you can add sub-categories of the main package category, such as Category:Package_(packagename)_core_test_cases and Category:Package_(packagename)_extended_test_cases. This split can be helpful for testers, if there are many test cases for a package; it could also be expressed by tools such as Fedora Easy Karma.
For our yum example, consider a third test case added to our previous two test cases:
• QA:Testcase_yum_install - to test installing a package
• QA:Testcase_yum_upgrade - to test upgrading the system
• QA:Testcase_yum_history - to test yum's history function
As before, all three must be in the category Category:Package_yum_test_cases and QA:Testcase_yum_upgrade must be in the category Category:Critical_path_test_cases. Additionally, you could place QA:Testcase_yum_install and QA:Testcase_yum_upgrade in a category Category:Package_yum_core_test_cases and QA:Testcase_yum_history in a category Category:Package_yum_extended_test_cases, and make both those categories sub-categories of Category:Package_yum_test_cases, if you wished to separate core and extended test cases for yum.
Test plan instructions
You do not have to write explicit test plan instructions if it is not necessary for the package in question; the existence of the categories will serve to make the tests discoverable by testers. You can, of course, link to the category page or the individual tests from anywhere else you choose, as well.
You can, if it would be useful for the package in question and if you choose, add instructions or hints for running the complete test plan for a package to the Category:Package_(packagename)_test_cases page; remember, category pages can be edited and used just as normal content pages within the Wiki system. You can then link to the category page from wherever else would be appropriate.
You could also include instructions for running some or all of the tests in some other page, on the Wiki or outside it, and then link either to the individual tests or to the category page.
You may also want to write a test plan specific to a particular event, such as a Test Day, in which case it would make most sense to include it in or link to it from the page for that event.
As you can see, there are many possible different scenarios for test plan instructions, so we leave this up to the discretion of those creating the test plan and test cases and test events.
Automation
If any of the test cases you create would be amenable to automated testing - that is, they could be tested without the need for manual hand-holding - you may look into integrating those test cases with the AutoQA system. If you contact the AutoQA team, they will be able to help and advise you with writing a script to perform the testing, and hooking it into the AutoQA system so that these tests can be run automatically whenever you change the package.
|
__label__pos
| 0.707014 |
Python String split()
The Python String split() method is a built-in function that splits the string based on the specified separator and returns a list of strings.
In this article, we will learn about the Python String split() method with the help of examples.
split() Syntax
The Syntax of split() method is:
str.split(separator, maxsplit)
split() Parameters
The split() method takes two parameters, and both are optional.
• separator (optional) – Delimiter at which the string split should happen. If not provided, whitespace is taken as a separator, and the string will split at whitespaces.
• maxsplit (optional) – An integer that tells us the maximum number of times the split should happen. If not provided, the default value is -1, which means there is no limit on the number of splits.
Example – If you would like to split the string on the occurrences of the first comma, you can set the maxsplit=1
The maxsplit=1 will split the string into 2 chunks—one with the string section before the first comma and another with the string section after the first comma.
split() Return Value
The split() method returns the list of strings after breaking the given string by the specified character.
Example 1: How split() works in Python?
# splits by whitespace
text = "Python is fun"
print(text.split())
# splits the text after 'is' string
text = "Python is fun"
print(text.split('is'))
# cannot split as the character is not found
text = "Python is fun"
print(text.split('|'))
# splits by comma
fruits ="Apple, Grapes, Orange, Watermelon"
print(fruits.split(','))
Output
['Python', 'is', 'fun']
['Python ', ' fun']
['Python is fun']
['Apple', ' Grapes', ' Orange', ' Watermelon']
Example 2: How split() works when maxsplit is specified?
# splits by whitespace
text = "Python is really fun"
print(text.split(' ', 1))
# splits by comma
fruits = "Apple, Grapes, Orange, Watermelon"
print(fruits.split(',', 0))
# splits by comma
fruits = "Apple, Grapes, Orange, Watermelon"
print(fruits.split(',', 1))
# splits by comma
fruits = "Apple, Grapes, Orange, Watermelon"
print(fruits.split(',', 2))
# splits by comma
fruits = "Apple, Grapes, Orange, Watermelon"
print(fruits.split(',', 3))
Output
['Python', 'is really fun']
['Apple, Grapes, Orange, Watermelon']
['Apple', ' Grapes, Orange, Watermelon']
['Apple', ' Grapes', ' Orange, Watermelon']
['Apple', ' Grapes', ' Orange', ' Watermelon']
Leave a Reply
Your email address will not be published.
Sign Up for Our Newsletters
Get notified of the best deals on our WordPress themes.
You May Also Like
Python String Isupper()
Python String isupper()
Table of Contents Hide isupper() Syntaxisupper() Parameterisupper() Return ValueExample 1: Demonstrating the working of isupper() method Example 2: Practical use case of isupper() in a program Python String isupper() method is…
View Post
Python Callable()
Python callable()
Table of Contents Hide callable() Syntax callable() Parameterscallable() Return ValueExample 1: How does callable() works?Example 2: When an Object is callable Example 3: When an Object is NOT callable The callable() function in…
View Post
Python All()
Python all()
Table of Contents Hide all() Syntaxall() Parametersall() Return ValueDifference between any() and all() functions in PythonExample 1 – Using all() function on Python ListsExample 2 – Using all() function on…
View Post
Python String Isdigit()
Python String isdigit()
Table of Contents Hide What are the valid digits in Python?isdigit() Syntaxisdigit() Parameters isdigit() Return valueExample 1: Working with Python string isdigit() methodExample 2: How do I check if a string…
View Post
|
__label__pos
| 0.960972 |
Logo: Relish
1. Sign in
Project: RSpec Rails 6.0
System generator spec
Scenarios
System generator
When
I run bundle exec rails generate rspec:system posts
Then
the features should pass
Then
the output should contain:
create spec/system/posts_spec.rb
System generator with customized `default-path`
Given
a file named ".rspec" with:
--default-path behaviour
And
I run bundle exec rails generate rspec:system posts
Then
the features should pass
Then
the output should contain:
create behaviour/system/posts_spec.rb
Last published 4 months ago by Jon Rowe.
|
__label__pos
| 0.991214 |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
use crate::Name;
use std::convert::{From, TryFrom};
/// A marker type that captures the relationships between a domain type (`Self`) and a protobuf type (`Self::Proto`).
pub trait DomainType
where
Self: Clone + Sized + TryFrom<Self::Proto>,
Self::Proto: prost::Name + prost::Message + Default + From<Self> + Send + Sync + 'static,
anyhow::Error: From<<Self as TryFrom<Self::Proto>>::Error>,
{
type Proto;
/// Encode this domain type to a byte vector, via proto type `P`.
fn encode_to_vec(&self) -> Vec<u8> {
use prost::Message;
self.to_proto().encode_to_vec()
}
/// Convert this domain type to the associated proto type.
///
/// This uses the `From` impl internally, so it works exactly
/// like `.into()`, but does not require type inference.
fn to_proto(&self) -> Self::Proto {
Self::Proto::from(self.clone())
}
/// Decode this domain type from a byte buffer, via proto type `P`.
fn decode<B: bytes::Buf>(buf: B) -> anyhow::Result<Self> {
<Self::Proto as prost::Message>::decode(buf)?
.try_into()
.map_err(Into::into)
}
}
// Implementations on foreign types.
//
// This should only be done here in cases where the domain type lives in a crate
// that shouldn't depend on the Penumbra proto framework.
use crate::penumbra::core::component::ibc::v1::IbcRelay;
use crate::penumbra::crypto::decaf377_rdsa::v1::{
BindingSignature, SpendAuthSignature, SpendVerificationKey,
};
use decaf377_rdsa::{Binding, Signature, SpendAuth, VerificationKey};
impl DomainType for Signature<SpendAuth> {
type Proto = SpendAuthSignature;
}
impl DomainType for Signature<Binding> {
type Proto = BindingSignature;
}
impl DomainType for VerificationKey<SpendAuth> {
type Proto = SpendVerificationKey;
}
impl From<Signature<SpendAuth>> for SpendAuthSignature {
fn from(sig: Signature<SpendAuth>) -> Self {
Self {
inner: sig.to_bytes().to_vec(),
}
}
}
impl From<Signature<Binding>> for BindingSignature {
fn from(sig: Signature<Binding>) -> Self {
Self {
inner: sig.to_bytes().to_vec(),
}
}
}
impl From<VerificationKey<SpendAuth>> for SpendVerificationKey {
fn from(key: VerificationKey<SpendAuth>) -> Self {
Self {
inner: key.to_bytes().to_vec(),
}
}
}
impl TryFrom<SpendAuthSignature> for Signature<SpendAuth> {
type Error = anyhow::Error;
fn try_from(value: SpendAuthSignature) -> Result<Self, Self::Error> {
Ok(value.inner.as_slice().try_into()?)
}
}
impl TryFrom<BindingSignature> for Signature<Binding> {
type Error = anyhow::Error;
fn try_from(value: BindingSignature) -> Result<Self, Self::Error> {
Ok(value.inner.as_slice().try_into()?)
}
}
impl TryFrom<SpendVerificationKey> for VerificationKey<SpendAuth> {
type Error = anyhow::Error;
fn try_from(value: SpendVerificationKey) -> Result<Self, Self::Error> {
Ok(value.inner.as_slice().try_into()?)
}
}
// Fuzzy Message Detection
use crate::penumbra::crypto::decaf377_fmd::v1::Clue as ProtoClue;
use decaf377_fmd::Clue;
impl DomainType for Clue {
type Proto = ProtoClue;
}
impl From<Clue> for ProtoClue {
fn from(msg: Clue) -> Self {
ProtoClue { inner: msg.into() }
}
}
impl TryFrom<ProtoClue> for Clue {
type Error = anyhow::Error;
fn try_from(proto: ProtoClue) -> Result<Self, Self::Error> {
proto.inner[..]
.try_into()
.map_err(|_| anyhow::anyhow!("expected 68-byte clue"))
}
}
// Consensus key
//
// The tendermint-rs PublicKey type already has a tendermint-proto type;
// this redefines its proto, because the encodings are consensus-critical
// and we don't vendor all of the tendermint protos.
use crate::penumbra::core::keys::v1::ConsensusKey;
impl DomainType for tendermint::PublicKey {
type Proto = ConsensusKey;
}
impl From<tendermint::PublicKey> for crate::penumbra::core::keys::v1::ConsensusKey {
fn from(v: tendermint::PublicKey) -> Self {
Self {
inner: v.to_bytes(),
}
}
}
impl TryFrom<crate::core::keys::v1::ConsensusKey> for tendermint::PublicKey {
type Error = anyhow::Error;
fn try_from(value: crate::core::keys::v1::ConsensusKey) -> Result<Self, Self::Error> {
Self::from_raw_ed25519(value.inner.as_slice())
.ok_or_else(|| anyhow::anyhow!("invalid ed25519 key"))
}
}
// IBC-rs impls
extern crate ibc_types;
use ibc_proto::ibc::core::channel::v1::Channel as RawChannel;
use ibc_proto::ibc::core::client::v1::Height as RawHeight;
use ibc_proto::ibc::core::connection::v1::ClientPaths as RawClientPaths;
use ibc_proto::ibc::core::connection::v1::ConnectionEnd as RawConnectionEnd;
use ibc_types::core::channel::ChannelEnd;
use ibc_types::core::client::Height;
use ibc_types::core::connection::{ClientPaths, ConnectionEnd};
use ibc_types::lightclients::tendermint::client_state::ClientState;
use ibc_types::lightclients::tendermint::consensus_state::ConsensusState;
impl DomainType for ClientPaths {
type Proto = RawClientPaths;
}
impl DomainType for ConnectionEnd {
type Proto = RawConnectionEnd;
}
impl DomainType for ChannelEnd {
type Proto = RawChannel;
}
impl DomainType for Height {
type Proto = RawHeight;
}
impl DomainType for ClientState {
type Proto = ibc_proto::google::protobuf::Any;
}
impl DomainType for ConsensusState {
type Proto = ibc_proto::google::protobuf::Any;
}
impl<T> From<T> for IbcRelay
where
T: ibc_types::DomainType + Send + Sync + 'static,
<T as TryFrom<<T as ibc_types::DomainType>::Proto>>::Error: Send + Sync + std::error::Error,
{
fn from(v: T) -> Self {
let value_bytes = v.encode_to_vec();
let any = pbjson_types::Any {
type_url: <T as ibc_types::DomainType>::Proto::type_url(),
value: value_bytes.into(),
};
Self {
raw_action: Some(any),
}
}
}
|
__label__pos
| 0.989061 |
Reader Level:
Article
Look at Covariance and Contravariance in Delegates
By Sateesh Arveti on Apr 15, 2010
In this article, we will look into Covariance and Contravariance in Delegates using C#.
In this article, we will look into Covariance and Contravariance in Delegates using C#. We know that delegate is type-safe function pointer referencing a method. Any method matching the delegate signature can be assigned to the delegate and can be called as a method. Once a delegate is assigned to a method, it behaves exactly as a method. Delegates provides below benefits:
1. We can pass methods as parameters to other methods.
2. To define callback methods.
3. Multiple methods can be called with a single delegate.
C# provides a degree of flexibility when matching a delegate type with the method signature. It doesn't require matching delegate signature exactly. Covariance allows us to have a more derived type as return type than specified in the delegate declaration. Similar way, Contravariance allows us to have less derived type as parameter type than specified in delegate. Let's see it with an example.
Covariance:
class parent
{
}
class child : parent
{
}
class Program
{
public delegate parent CovarianceHandler();
public static parent PCovariance()
{
return new parent();
}
public static child CCovariance()
{
return new child();
}
static void Main(string[] args)
{
CovarianceHandler handler = PCovariance;
Console.WriteLine(handler().GetType().ToString());
CovarianceHandler handler1 = CCovariance;
Console.WriteLine(handler1().GetType().ToString());
}
}
Because of Covariance, we are able to call method that is having return type[child] derived from return type[parent] in delegate declaration.
Contravariance:
class parent
{
}
class child : parent
{
}
class Program
{
public delegate parent ContravarianceHandler(child c);
public static parent PContravariance(parent p)
{
return p;
}
public static parent CContravariance(child c)
{
return c as parent;
}
static void Main(string[] args)
{
ContravarianceHandler handler = PContravariance;
Console.WriteLine(handler(new child()).GetType().ToString());
ContravarianceHandler handler1 = CContravariance;
Console.WriteLine(handler1(new child()).GetType().ToString());
}
}
Here, we are able to call PContravariance having parameter type [parent] less derived than the type declared in delegate signature using ContraVariance. By using this, we can have a single event handler having base type as parameter type and use it with methods having derived type as parameter type for calling.
I am ending the things here. I hope this article will be helpful for all.
Sateesh Arveti
I hold Bachelors degree in Computer Science along with MCSD,MCTS and MVP for the year 2009. Areas of Interest: C#, WPF, WF, silverlight, ASP.NET, Oracle and SQL Server.
COMMENT USING
|
__label__pos
| 0.998117 |
Performance testing is the process of understanding how the application behaves under various levels of load. In general, we measure latency, throughput, and utilization while simulating virtual users to simultaneously access the application. One of the main performance objectives of an application is to maintain the environment with low latency, high throughput, and low utilization.
Scope of Performance Testing
Load Testing
Evaluates the ability of the application to perform under expected user loads. This is done to identify performance bottlenecks before going live.
Stress Testing
Evaluates how an application handles high traffic and data processing under extreme workloads. This is done to identify breaking point of an application.
Volume Testing
Evaluates software behavior under an increasing volume of stored and processed data. This is done to check how the application is able to handle varying database volumes.
Scalability Testing
Determine the capability of the application to scale up to support an increase in user load, number of transactions or data volume. This helps plan the capacity addition for the application.
Endurance Testing
Determine whether the application is able to handle the expected load over a long period of time. This is done to discover how the system behaves under sustained use.
Spike Testing
Evaluate how the system behaves when there is a sudden change in load generated by users, transactions or data volume. This is done to determine if the system will be able to handle dramatic changes in load.
Parameters Measured During Performance Testing
• Response time of end-to-end transaction
• Performance of application server components under various loads
• Performance of the database components under various loads
• Performance of system resources under various loads.
• Network delay between the server and clients
Our Approach
Step 1
Identify the Test Environment & Performance Acceptance criteria.
Step 2
Plan, Design Tests and Configure the Test Environment
Step 3
Implement the Test Design & Execute the Test
Step 4
Analyze Results and Prepare Reports
|
__label__pos
| 0.578691 |
How can I recover my Debian root password?
How can I recover my Debian root password?
Run clear if your prompt is obscured with console text. Run mount -o remount,rw / to mount the system volume. Run passwd and follow the prompts to change the root password. Reboot the server.
What is the root password for Debian Live CD?
The answer can be found in the Debian Live manual under the section 10.1 Customizing the live user. It says: It is also possible to change the default username “user” and the default password “live”.
How do I bypass root password in Linux?
Navigate until you get to the ro quiet splash section and add rw init=/bin/bash . Then press ctrl + x or hit F10 to boot into a single-user mode as shown below. To reset the forgotten root password in Linux Mint, simply run the passwd root command as shown. Specify the new root password and confirm it.
How do I reset my Debian 11 password?
How to Reset Root Password on Debian 11
1. Step 1: Reboot Debian System.
2. Step 2: Edit Boot Grub Configuration.
3. Step 3: Reset Password.
How do I change my Debian 11 password?
Linux: Reset User Password
1. Open a terminal window.
2. Issue the command sudo passwd USERNAME (where USERNAME is the name of the user whose password you want to change).
3. Type your user password.
4. Type the new password for the other user.
5. Retype the new password.
6. Close the terminal.
What is the password for Debian Live user?
Debian Live login “user” and password is “live”.
How do you unlock a root account in Linux?
In order to unlock the root account, you have to use the “usermod” command with the “-U” and specify the root account.
How do I find the root user in Linux?
You need to use any one of the following command to log in as superuser / root user on Linux: su command – Run a command with substitute user and group ID in Linux. sudo command – Execute a command as another user on Linux….
Category List of Unix and Linux commands
User Environment exit • who
How do I reset my root password?
In some situations, you may need to access an account for which you’ve lost or forgotten a password.
1. Step 1: Boot to Recovery Mode. Restart your system.
2. Step 2: Drop Out to Root Shell.
3. Step 3: Remount the File System with Write-Permissions.
4. Step 4: Change the Password.
How to reset root password on Debian 9?
Use “down arrow” key for scrolling down. Go to the line that starts with the word “linux” and use “forward” arrow or press “End” button to go to the end of the line, and then add “init=/bin/bash“. Reset root password on Debian 9 – Editing Kernel Commands. After you have added the entry, press “Ctrl + x or F10” to boot Debian 9.
How do I boot Linux without knowing the root password?
It is possible to boot a system and log on to the root account without knowing the root password as long as one has access to the console keyboard. This is a procedure which requires no external boot disks and no change in BIOS boot settings. Here, “Linux” is the label for booting the Linux kernel in the default Debian install.
What do I do if I Forgot my root password?
Sponsored Link If you forgot your root password for your debian server use the following procedure to reset. Boot to the GRUB menu. Then, press (for edit) before Linux has a chance to boot.
How to change the root user password in Linux?
So, use below command to mount the root file system in “ read-write mode “. Finally, change the root user password using “ passwd ” command. Reboot your system and use the new password we set now for the root user on your system. That’s All.
Begin typing your search term above and press enter to search. Press ESC to cancel.
Back To Top
|
__label__pos
| 0.999962 |
#!/bin/bash # This builds and installs Unity. Also includes setup for Ubuntu Natty # See http://askubuntu.com/questions/28470/how-do-i-build-unity-from-source/28472#28472 # Change this to where you want everything installed: installprefix=/opt/unity # flag to update nux and or unity nux=1 unity=1 function set_env() { export PKG_CONFIG_PATH=$installprefix/lib/pkgconfig:${PKG_CONFIG_PATH} export LD_LIBRARY_PATH=$installprefix/lib:${LD_LIBRARY_PATH} export LD_RUN_PATH=$installprefix/lib:${LD_RUN_PATH} } function unset_env() { unset PKG_CONFIG_PATH unset LD_LIBRARY_PATH unset LD_RUN_PATH } function install_prerequisites() { sudo apt-get install bzr cmake compiz-dev gnome-common libbamf-dev libboost-dev libboost-serialization-dev libcairo2-dev libdbusmenu-glib-dev libdee-dev libgconf2-dev libgdk-pixbuf2.0-dev libglew1.5-dev libglewmx1.5-dev libglib2.0-dev libindicator-dev libpango1.0-dev libpcre3-dev libsigc++-2.0-dev libunity-misc-dev libutouch-geis-dev } function launch() { export PATH="${installprefix}/bin:${PATH}" compiz --replace & } function clone() { # Nux bzr branch lp:nux # Unity bzr branch lp:unity } function make_install_nux() { if [ "$nux" == "1" ] then cd nux make -j4 && sudo make -j4 install cd .. fi } function make_install_unity() { if [ "$unity" == "1" ] then set_env cd unity/build make -j4 && sudo make -j4 install if [ ! -d $installprefix/share/unity/places ] then sudo mkdir $installprefix/share/unity/places fi sudo cp /usr/share/unity/places/* $installprefix/share/unity/places/ cd ../.. unset_env fi } function configure() { # have to build and install nux for unity to configure if [ "$nux" == "1" ] then cd nux ./autogen.sh --disable-documentation --prefix=$installprefix cd .. make_install_nux fi if [ "$unity" == "1" ] then set_env cd unity if [ ! -d build ] then mkdir build fi cd build cmake .. -DCMAKE_BUILD_TYPE=Debug -DCOMPIZ_PLUGIN_INSTALL_TYPE=local -DCMAKE_INSTALL_PREFIX=$installprefix cd ../.. unset_env make_install_unity fi } function makemakeinstall() { make_install_nux make_install_unity } function pull() { if [ "$nux" == "1" ] then cd nux bzr pull cd .. fi if [ "$unity" == "1" ] then cd unity bzr pull cd .. fi } function print_usage() { echo "Usage:" echo "$0 clone|configure|make|pull|prerequisites|run [nux|unity]" echo "" echo "clone - bzr clone each of the necessary repositories" echo "configure - Build the code (runs autogen, make, make install)" echo "make - Rebuild the code (runs make, make install)" echo "pull - bzr pull each of the repositories" echo "prerequisites - Install ubuntu pre-requisites" echo "run - Launch the local Unity build" echo "" echo "To get started run: " echo "$0 prerequisites" echo "$0 clone" echo "$0 configure" echo "$0 run" } # skip argument parsing if we are being sourced in order # to setup the wayland environment if [ "/bin/bash" != "$0" ] then set -e # exit script if anything fails #set -x # enable debugging # print usage if no arguments if [ $# -eq 0 ] then print_usage `basename $0` exit 1 fi # check if only nux or unity should be updated if [ "$2" == "unity" ] then nux="0" elif [ "$2" == "nux" ] then unity="0" fi # handle the input argument if [ "$1" == "run" ] then launch elif [ "$1" == "pull" ] then pull elif [ "$1" == "clone" ] then clone elif [ "$1" == "configure" ] then configure elif [ "$1" == "make" ] then makemakeinstall elif [ "$1" == "prerequisites" ] then install_prerequisites else print_usage `basename $0` fi fi
|
__label__pos
| 0.851743 |
grep command in linux
The word grep stands for Globally Regular Expression Print. Using grep command in Linux/Unix, we can search one or more files for lines that contains pattern.
Syntax:
grep [options] pattern [files]
Options:
Option Description
-b Displays the block number at the beginning of each line.
-c Displays the number of matched lines
-h Displays the matched lines, but do not display the file names
-i To ignore Case Sensitivty
-l Displays the filename, but do not display the matched lines.
-n Displays the matched lines and their line numbers
-v Displays the all lines that do not match
-w Match whole word
Examples:
1. To search for a word root in /etc/passwd file
grep command in linux
2. To search block number of the result pattern, this gives list of the lines pattern found along with the block number of line.
grep command in linux1
3. To count number of lines the pattern
grep command in linux2
4. If we want only lines and no file names we can go with -h option.
grep command in linux3
5. If we want only file names and no lines the use -l option.
grep command in linux4
6. In some cases we may require the output of content excluding the lines that we find the pattern in such cases we have to go with -v option.
grep command in linux
Related Posts
Responses are currently closed, but you can trackback from your own site.
Comments are closed.
Powered by k2schools
|
__label__pos
| 0.895612 |
Firebase Cloud Messaging
Firebase Cloud Messaging (FCM) adalah solusi pertukaran pesan lintas platform yang dapat Anda andalkan untuk mengirim pesan tanpa biaya.
Dengan FCM, Anda dapat memberi tahu aplikasi klien bahwa email baru atau data lainnya tersedia untuk disinkronkan. Anda dapat mengirim pesan notifikasi untuk mendorong interaksi kembali dan retensi pengguna. Untuk kasus penggunaan seperti instant messaging, pesan dapat mentransfer payload hingga 4.000 byte ke aplikasi klien.
Memakai Google Cloud Messaging API yang tidak digunakan lagi? Pelajari cara migrasi ke FCM lebih lanjut.
Penyiapan iOS+ Penyiapan Android Penyiapan Web Penyiapan C++ Penyiapan Unity
Kemampuan utama
Mengirim pesan notifikasi atau pesan data Mengirim pesan notifikasi yang ditampilkan kepada pengguna. Atau mengirim pesan data dan menentukan sepenuhnya apa yang terjadi dalam kode aplikasi. Lihat Jenis pesan.
Penargetan pesan serbaguna Mendistribusikan pesan ke aplikasi klien dengan salah satu dari 3 cara, yaitu ke satu perangkat, ke grup perangkat, atau ke perangkat yang berlangganan topik.
Mengirim pesan dari aplikasi klien Mengirim konfirmasi, chat, dan pesan lain dari perangkat kembali ke server melalui saluran koneksi FCM yang andal dan hemat baterai.
Bagaimana cara kerjanya?
Implementasi FCM mencakup dua komponen utama untuk mengirim dan menerima pesan:
1. Lingkungan tepercaya seperti Cloud Functions for Firebase atau server aplikasi yang akan digunakan untuk membuat, menargetkan, dan mengirim pesan.
2. Aplikasi klien Apple, Android, atau web (JavaScript) yang menerima pesan melalui layanan transportasi spesifik platform yang sesuai.
Anda dapat mengirim pesan melalui Firebase Admin SDK atau protokol server FCM. Anda dapat menggunakan Notifications Composer untuk pengujian dan untuk mengirimkan pesan pemasaran atau engagement menggunakan analisis dan penargetan bawaan yang andal atau segmen kustom yang diimpor.
Pelajari ringkasan arsitektur untuk mengetahui detail lebih lanjut dan informasi penting tentang komponen FCM.
Alur implementasi
Menyiapkan FCM SDK Siapkan Firebase dan FCM pada aplikasi sesuai petunjuk penyiapan untuk platform Anda.
Mengembangkan aplikasi klien Tambahkan penanganan pesan, logika langganan topik, atau fitur opsional lainnya ke aplikasi klien Anda. Selama tahap pengembangan, Anda dapat mengirimkan pesan pengujian dengan mudah dari Notifications Composer.
Mengembangkan server aplikasi Tentukan apakah Anda ingin menggunakan Firebase Admin SDK atau salah satu protokol server untuk membuat logika pengiriman, yaitu logika untuk mengautentikasi, membuat permintaan kirim, menangani respons, dan sebagainya. Kemudian, buat logika di lingkungan tepercaya Anda. Perlu diperhatikan bahwa jika ingin menggunakan pertukaran pesan upstream dari aplikasi klien, Anda harus menggunakan XMPP, dan bahwa Cloud Functions tidak mendukung koneksi tetap yang diperlukan oleh XMPP.
Langkah berikutnya
• Jalankan contoh Panduan Memulai Android atau iOS. Dengan contoh ini, Anda dapat menjalankan dan meninjau kode untuk mengirim pesan pengujian ke satu perangkat menggunakan Firebase console.
• Cobalah tutorial untuk Android atau iOS.
• Tambahkan Firebase Cloud Messaging ke aplikasi Android, Apple, atau Web Anda.
• Siapkan lingkungan tepercaya untuk membuat dan mengirim permintaan pesan. Anda dapat menulis logika pengiriman menggunakan Admin SDK, dan men-deploy kode tersebut dengan mudah di Cloud Functions for Firebase atau lingkungan cloud lainnya yang dikelola oleh Google. Atau, Anda dapat melakukan pengembangan server menggunakan protokol server FCM.
• Pelajari lebih lanjut cara mengirim payload data, menetapkan prioritas pesan, dan opsi pertukaran pesan lainnya yang tersedia dengan FCM.
• Migrasikan implementasi GCM Android atau Apple yang sudah ada agar Anda dapat menggunakan Firebase Cloud Messaging.
|
__label__pos
| 0.988721 |
Mengenal Konsep dan Manfaat Framework dalam Pengembangan Aplikasi
Framework adalah kerangka atau rangkaian alat bantu yang digunakan oleh para pengembang perangkat lunak untuk membangun dan mengembangkan aplikasi dengan lebih efisien dan efektif. Dalam pengembangan aplikasi, framework memberikan kerangka kerja yang jelas dan struktur untuk memandu para pengembang dalam menulis kode dan membangun aplikasi dengan lebih cepat dan mudah.
Salah satu manfaat utama dari menggunakan framework dalam pengembangan aplikasi adalah kemampuan untuk menghemat waktu dan usaha dalam pengembangan aplikasi. Framework biasanya dilengkapi dengan serangkaian alat bantu seperti pustaka, modul, dan bahasa pemrograman yang telah disediakan sebelumnya sehingga pengembang tidak perlu mengulangi proses pembangunan dari awal. Selain itu, framework juga mempercepat proses debugging dan pengujian aplikasi, serta meningkatkan kualitas dan keamanan aplikasi.
Konsep framework sendiri memandang aplikasi sebagai sebuah objek yang terdiri dari komponen-komponen atau elemen yang saling berhubungan. Framework menyediakan struktur dan kerangka kerja yang jelas untuk membangun aplikasi dengan menghubungkan komponen-komponen tersebut secara sistematis dan terstruktur. Dalam framework, pengembang perangkat lunak tidak perlu membuat komponen aplikasi dari awal, melainkan dapat memanfaatkan modul-modul dan komponen-komponen yang telah disediakan sebelumnya oleh framework.
Dalam pengembangan aplikasi, framework juga mempermudah proses kolaborasi antar pengembang karena terdapat standar yang telah ditetapkan dalam menggunakan framework tersebut. Hal ini memudahkan pengembang untuk bekerja sama dalam membangun aplikasi tanpa khawatir adanya perbedaan dalam penulisan kode dan metode pengembangan aplikasi.
Secara keseluruhan, penggunaan framework dalam pengembangan aplikasi memiliki manfaat yang sangat besar, terutama dalam hal efisiensi waktu dan usaha. Dengan konsep dan manfaat yang dimilikinya, framework menjadi sebuah alat bantu yang sangat penting bagi para pengembang perangkat lunak untuk membangun dan mengembangkan aplikasi secara lebih cepat, mudah, dan terstruktur.
Konsep framework pada pengembangan aplikasi adalah penggunaan kerangka kerja atau rangkaian struktur yang telah tersusun dan terintegrasi dengan baik sehingga memudahkan developer dalam mengembangkan sebuah aplikasi. Framework memberikan batasan dalam membangun aplikasi, namun dalam batasan tersebut terdapat banyak fitur dan komponen yang dapat memudahkan developer dalam mengembangkan aplikasi.
Manfaat penggunaan framework pada pengembangan aplikasi adalah mempercepat proses pengembangan aplikasi, memudahkan dalam perawatan dan perbaikan aplikasi, meningkatkan kualitas dan keamanan aplikasi, serta mempermudah dalam melakukan debugging dan testing.
Selain itu, penggunaan framework juga dapat meningkatkan efisiensi waktu dan biaya dalam pengembangan aplikasi karena tidak perlu membuat fitur atau komponen dari awal. Framework telah menyediakan banyak fitur dan komponen yang siap digunakan oleh developer sehingga dapat menghemat waktu dan biaya yang dikeluarkan dalam pengembangan aplikasi.
Dalam pengembangan aplikasi, terdapat banyak framework yang dapat digunakan, baik untuk frontend maupun backend. Beberapa contoh framework populer untuk frontend adalah Angular, React, dan Vue.js, sedangkan untuk backend adalah Laravel, Ruby on Rails, dan Django. Pemilihan framework yang tepat dan sesuai dengan kebutuhan aplikasi sangat penting untuk mempercepat proses pengembangan, meningkatkan kualitas aplikasi, dan menghemat biaya dan waktu.
Manfaat Framework dalam Pengembangan Aplikasi:
1. Mempercepat Pengembangan Aplikasi Framework membantu dalam mempercepat pengembangan aplikasi karena banyak fitur yang sudah tersedia dan terintegrasi dalam framework tersebut. Dengan menggunakan framework, programmer tidak perlu lagi membuat fitur yang sama dari awal, sehingga waktu yang dibutuhkan untuk pengembangan aplikasi bisa lebih cepat.
2. Meningkatkan Produktivitas Dengan menggunakan framework, programmer bisa lebih produktif karena tidak perlu lagi membuat kode dari awal. Sebagai contoh, framework sudah menyediakan sistem routing dan database, sehingga programmer tidak perlu lagi membuat dari awal.
3. Meminimalkan Kesalahan Framework membantu programmer dalam meminimalkan kesalahan karena sudah banyak fitur yang sudah diuji dan terbukti stabil. Selain itu, framework juga menyediakan dokumentasi yang lengkap dan mudah dipahami, sehingga programmer bisa dengan mudah menemukan dan mengatasi kesalahan yang terjadi.
4. Mudah dalam Perawatan dan Pengembangan Dengan menggunakan framework, aplikasi yang dibuat bisa lebih mudah dalam perawatan dan pengembangan. Programmer bisa dengan mudah melakukan perubahan dan penambahan fitur baru tanpa perlu mengubah seluruh struktur aplikasi.
5. Memiliki Komunitas yang Besar Framework biasanya memiliki komunitas yang besar, sehingga programmer bisa dengan mudah mencari informasi dan solusi atas masalah yang terjadi dalam pengembangan aplikasi. Selain itu, komunitas juga bisa membantu dalam meningkatkan kualitas aplikasi yang dibuat.
6. Menyediakan Keamanan yang Lebih Baik Framework menyediakan fitur keamanan yang lebih baik dibandingkan dengan membuat aplikasi dari awal. Sebagian besar framework sudah dilengkapi dengan fitur keamanan seperti proteksi terhadap serangan SQL injection, CSRF, dan XSS.
7. Memudahkan dalam Skalabilitas Framework membantu dalam memudahkan skalabilitas aplikasi karena sudah banyak fitur yang tersedia untuk menangani pertumbuhan aplikasi. Dengan menggunakan framework, programmer bisa lebih mudah dalam menambahkan fitur baru untuk mengatasi pertumbuhan aplikasi.
Dalam pengembangan aplikasi, framework menjadi sangat penting untuk membantu mempercepat pengembangan, meningkatkan produktivitas, meminimalkan kesalahan, memudahkan perawatan dan pengembangan, serta menyediakan keamanan dan skalabilitas yang lebih baik. Oleh karena itu, penting bagi para developer untuk memahami konsep dan manfaat dari framework dalam pengembangan aplikasi.
Salah satu manfaat utama dari menggunakan framework dalam pengembangan aplikasi adalah mempercepat proses pengembangan aplikasi dengan menyediakan struktur dan komponen dasar yang dapat digunakan ulang. Selain itu, penggunaan framework juga membantu dalam meningkatkan kualitas kode dengan menetapkan praktik terbaik dan standar dalam pengembangan aplikasi.
Konsep framework sendiri merujuk pada kumpulan library dan komponen yang dirancang untuk mempercepat proses pengembangan aplikasi dengan menyediakan beberapa fungsi yang dapat digunakan ulang. Dengan menggunakan framework, pengembang dapat menghemat waktu dan usaha yang diperlukan dalam membuat aplikasi dari awal, karena mereka dapat memanfaatkan fitur dan fungsionalitas yang sudah ada.
Dalam pengembangan aplikasi, framework juga memainkan peran penting dalam memastikan keamanan aplikasi. Beberapa framework menawarkan fitur keamanan bawaan, seperti perlindungan terhadap serangan SQL injection, cross-site scripting (XSS), dan serangan keamanan lainnya. Dengan demikian, pengembang dapat yakin bahwa aplikasi yang mereka kembangkan memiliki tingkat keamanan yang lebih baik.
Selain itu, penggunaan framework juga membantu dalam mempermudah proses debugging dan pemeliharaan aplikasi. Dalam beberapa kasus, menggunakan framework dapat membantu dalam mengidentifikasi masalah dalam kode dan mempercepat proses debugging.
Secara keseluruhan, menggunakan framework dalam pengembangan aplikasi dapat membantu pengembang dalam menghemat waktu dan usaha, meningkatkan kualitas kode, dan memastikan keamanan aplikasi. Oleh karena itu, penting bagi pengembang untuk mempelajari konsep dan manfaat framework agar dapat memilih dan mengimplementasikan framework yang tepat untuk kebutuhan pengembangan aplikasi mereka.
Framework sangat dibutuhkan oleh developer karena beberapa alasan. Pertama, framework menyediakan kerangka kerja atau struktur yang terbukti efektif dalam mengembangkan aplikasi. Dengan memanfaatkan framework, developer dapat menghindari membuat struktur dari awal yang mungkin memakan waktu dan sumber daya yang banyak.
Kedua, framework menyediakan berbagai fitur dan fungsi bawaan yang siap digunakan, seperti validasi data, manajemen database, dan sistem autentikasi. Dengan menggunakan fitur-fitur ini, developer dapat menghemat waktu dan usaha dalam mengembangkan aplikasi.
Ketiga, framework menyediakan dokumentasi yang lengkap dan tutorial yang mudah diikuti. Hal ini memudahkan developer dalam mempelajari dan mengimplementasikan framework pada proyek-proyek mereka.
Keempat, framework juga membantu mempercepat proses pengembangan dengan menggunakan pola-pola yang terbukti efektif dan sudah diuji coba. Framework juga dapat membantu dalam memelihara kode yang terstruktur dan mudah dipahami oleh developer lainnya, bahkan jika mereka tidak terbiasa dengan kode yang ditulis.
Dengan demikian, menggunakan framework dapat membantu developer dalam mengembangkan aplikasi dengan lebih cepat, efektif, dan terstruktur. Selain itu, framework juga dapat membantu menghemat waktu dan usaha dalam pengembangan aplikasi, sehingga developer dapat lebih fokus pada pengembangan fitur-fitur yang lebih kompleks dan inovatif.
Dalam pengembangan aplikasi, framework memegang peran penting untuk membantu developer dalam membangun aplikasi yang berkualitas dengan waktu yang lebih cepat dan efisien. Framework menyediakan struktur dan pola kerja yang telah terbukti efektif dalam mempermudah pengembangan aplikasi, sehingga developer dapat lebih fokus pada penyelesaian masalah bisnis yang lebih penting.
Dalam artikel ini, telah dijelaskan tentang pengenalan dan beberapa contoh framework terkenal seperti Angular, React, Vue.js, Ruby on Rails, dan Laravel. Setiap framework memiliki kelebihan dan kekurangan masing-masing, sehingga dalam memilih framework untuk digunakan dalam pengembangan aplikasi, perlu dilakukan evaluasi dan penyesuaian terhadap kebutuhan proyek dan keahlian developer yang tersedia.
Dengan menggunakan framework, developer dapat meningkatkan efisiensi dan efektivitas dalam pengembangan aplikasi, meminimalkan risiko kesalahan, meningkatkan kualitas, dan menghemat waktu dan biaya. Oleh karena itu, pengetahuan tentang konsep dan manfaat framework dalam pengembangan aplikasi sangat penting bagi developer untuk memastikan kesuksesan proyek yang dibangun.
Demikianlah pembahasan mengenai framework dalam pengembangan aplikasi. Dari pembahasan di atas, dapat disimpulkan bahwa framework sangatlah penting dalam mempercepat proses pengembangan aplikasi dan mempermudah developer dalam mengembangkan aplikasi dengan lebih cepat dan efisien. Dalam pemilihan framework, hal yang perlu diperhatikan adalah fitur-fitur yang disediakan, dokumentasi, dan komunitas pengguna yang aktif. Dengan pemilihan framework yang tepat, dapat membantu developer dalam memaksimalkan potensi pengembangan aplikasi dan menghasilkan aplikasi yang lebih baik dan efisien.
Namun, perlu diingat bahwa framework bukanlah satu-satunya kunci dalam pengembangan aplikasi yang berhasil. Kualitas kode, arsitektur aplikasi, dan pemilihan teknologi lainnya juga memiliki peran penting dalam kesuksesan pengembangan aplikasi. Oleh karena itu, developer perlu menguasai konsep-konsep fundamental dalam pengembangan aplikasi dan memperbarui pengetahuan secara berkala untuk terus beradaptasi dengan perkembangan teknologi terbaru.
|
__label__pos
| 0.999497 |
1
I'm aware of these posts
How do you sign an verify a message in javascript proving you own an Ethereum address?
How does one properly use ecrecover to verify Ethereum signatures?
I'd like to sign a message and then verify it. I use the following command line in the geth terminal.
var msg = web3.sha3('Schoolbus')
var signature = web3.eth.sign(web3.eth.accounts[0], msg)
var r = signature.slice(0, 66)
var s = '0x' + signature.slice(66, 130)
var v = '0x' + signature.slice(130, 132)
v = web3.toDecimal(v)
Then I use the smart contract below, and call:
call_ecover(r, s, v, msg)
But what i get is: 0x0000000000000000000000000000000000000000
pragma solidity ^0.5.0;
contract Call_verify{
function call_ecover(bytes32 r, bytes32 s, uint8 v,
bytes32 hash)external pure returns (address){
bytes memory prefix = "\x19Ethereum Signed
Message:\n32";
bytes32 prefixedHash =
keccak256(abi.encodePacked(prefix,hash));
return ecrecover(prefixedHash, v, r, s);
}
}
Note that I'm using compiler version 0.5.3 on remix.
Question: Why cannot I get the return value of ecrecover() function in my contract? Am I missing anything?
2 Answers 2
2
According to the documentation, it’s web3.eth.sign(data, address). I think you inversed the parameters. See https://web3js.readthedocs.io/en/1.0/web3-eth.html#sign.
Also, do you send the good hash in the call_ecover function? I think you need to send the hash of msg (in your case, a hash of a hash: web3.sha3(msg)).
4
• You don't have to send hash of hash, you have to send what was signed.
– Sanjay S B
Jul 17, 2019 at 5:31
• In the code, msg is the hash of 'Schoolbus’ and call_ecover needs the hash of the msg so in this case it’s a hash of a hash.
– n1c01a5
Jul 17, 2019 at 11:09
• In a digital signature, when you are signing a message, it means you are signing a hash of the message. This is used to verify the origin as well as integrity of the message. You can check the working logic in my answer. I have hashed SchoolBus only once before signing. This same hash is given as an input to the ecrecover function in solidity
– Sanjay S B
Jul 17, 2019 at 11:42
• Yes I agree with you and your code seems more clean but in the example of Ay. the message is a hash.
– n1c01a5
Jul 17, 2019 at 21:56
2
The following code snippet works:
//pragma solidity ^0.5.0
function checkSignature(bytes32 h, uint8 v, bytes32 r, bytes32 s) public pure returns (address signer) {
bytes memory prefix = "\x19Ethereum Signed Message:\n32";
bytes32 prefixedHash = keccak256(abi.encodePacked(prefix,h));
signer = ecrecover(prefixedHash, v, r, s);
}
//web3 1.0
//multisig is my constract instance and second is an account address.
const message = "SchoolBus";
const h = web3.utils.soliditySha3(message);
let signature = await web3.eth.sign(h, second);
var r = signature.slice(0, 66);
var s = "0x" + signature.slice(66, 130);
var v = "0x" + signature.slice(130, 132);
v = web3.utils.toDecimal(v);
v = v + 27;
const result = await multisig.checkSignature(h, v, r, s);
//result === second
Note: web3.sha3 is a method from v0.2x. in v1.0 the function used is as described above. ecrecover gets the signer details from a piece of data, usually a hash and the signature obtained when the signer signed the data.
Your Answer
By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.
Not the answer you're looking for? Browse other questions tagged or ask your own question.
|
__label__pos
| 0.808737 |
BSOD When Installing Windows Server 2022
The Problem
When attempting to boot/install Windows Server 2022, the installer crashes while booting and presents a stop code of DRIVER_IRQL_NOT_LESS_OR_EQUAL relating to storport.sys
Background
I have a set of 4 Cisco UCS C240 M3 servers that I run Hyper-V and Storage Spaces Direct on for a small Hyper-Converged cluster and some supporting infrastructure. Two of the servers serve as the HCI while the other two serve as my VMM and Backup server. Previously, I had been running Windows Server 2019 on all of the servers without any issues. I decided to run Server 2022 through it’s paces and play with some of the new features. I first re-imaged the pair of HCI servers. I created a bootable USB drive (UEFI Non-CSM) with Rufus and easily installed the OS on both servers. I then moved on to the third server, my VMM server, using the same boot drive. The booting screen appeared and before the spinning circle completed two revolutions I got a blue screen.
Troubleshooting
Wondering if something had gone awry with the hardware, I attempted to do the same with the fourth box. Same type of hardware, same result. The only difference between the two sets of boxes is the storage controllers. The HCI boxes make use of HBA controllers whereas the other two boxes make use of RAID controllers (LSI 9271CV-8i to be exact). I first took at look at the firmware. Both controllers were on the same firmware (23.33.1-0060). I downloaded and booted up the Cisco HUU ISO 3.0.4s to check if there was a newer version. Nope. I went ahead and re-flashed the firmware anyway to see if that would resolve the issue. Spoiler, it didn’t. My next thing to try was drivers. Unfortunately, this is a bit of a trickier problem as we can’t just hit F6 and pop in a floppy.
The Fix
In order to fix this issue, I needed to inject the appropriate drivers into the wims. To do this, I needed to inject the drivers into the boot.wim and install.wim from the media. Luckily, since I was using a USB drive to do the install, I could just swap out the wims on the flash drive. If you are using a CD, you’ll need to re-create the ISO using the utility of your choice.
1. First, we need to setup a quick folder structure. I created a set of folders in C:\temp and named them Mount, Drivers, and Wims. The names aren’t important, but rather, their purpose.
2. Next, we need to mount the Server 2022 ISO and copy the install.wim and boot.wim from the sources directory of the media to the Wims folder in our temp directory. You can do it via clicking through the GUI, or via PowerShell
Mount-DiskImage <path to iso>
Copy-Item -Path D:\sources\*.wim -Destination C:\temp\Wims\
Dismount-DiskImage -DevicePath \\.\CDROM0
After copying the wims, you can dismount the ISO.
3. Since we’re going to be adding data to the wims, we need to first remove the read-only flag.
Set-ItemProperty -Path C:\temp\Wims\install.wim -Name IsReadOnly -Value $false
Set-ItemProperty -Path C:\temp\Wims\boot.wim -Name IsReadOnly -Value $false
4. Next, we’ll need to accquire our drivers. Once you’ve got all the drivers you need, copy them to the Drivers folder like so. If you have multiple drivers, it’s a good idea to store each set in it’s own folder.
5. We’ll process boot.wim first:
$indexes = 1,2
foreach ($i in $indexes) {
Mount-WindowsImage -Path C:\temp\Mount -ImagePath C:\temp\Wims\boot.wim -Index $i
Add-WindowsDriver -Path C:\temp\Mount -Driver C:\temp\Drivers -Recurse
Dismount-WindowsImage -Path C:\temp\Mount -Save
}
6. Now we need to identify which editions of Windows Server we’re going to add our drivers to. If you know you’re only going to ever deploy Standard (Desktop Experience), you can opt to add the drivers to just that index.
$indexes = 1,2,3,4
foreach ($i in $indexes) {
Mount-WindowsImage -Path C:\temp\Mount -ImagePath C:\temp\Wims\install.wim -Index $i
Add-WindowsDriver -Path C:\temp\Mount -Driver C:\temp\Drivers -Recurse
Dismount-WindowsImage -Path C:\temp\Mount -Save
}
7. At this point, all we need to do is copy the two wims to the sources folder on our installation media. Once we do that, we should get past the BSOD.
Installation was successful, and I now have Server 2022 running on all of the servers in my lab.
Crafting a Leather Desk Pad with Integrated PowerPlay
Recently, I’ve been looking at adding a desk pad to my desk to protect the wood. One of my requirements was that I wanted genuine leather, not the PU crap or other synthetic materials that many sellers on Amazon try to pawn off as leather. Wading through the seemingly endless list of junk, I did find quite a few listings that claimed to be real leather. The next part was trying to find one that was the size that I needed. I wanted something at least 36in (914mm) x 13in (330mm). That narrowed down the pickings, but also upped the price with most units coming in at $80 or more. I thought to myself, I can make this cheaper. So I did… Sorta.
The starting point
The Requirements
Just like any proper project, I started out forming a list of requirements. If I was going to go the custom route, it had betted damn well check all of my boxes.
• 14in (355mm) x 40in (1016mm)
• Top Grain or Full Grain Leather (Black or Brown)
• Integrated PowerPlay
The Supplies
Thankfully, the supplies list for this is pretty short. I just needed some leather, some foam backing, and something to glue the two together with. For the leather, I opted for a side of chrome tanned, black stoned oil finish leather from Tandy Leather. This ran me $150. Yes, it was more expensive than buying a desk pad off of Amazon, but I can get up to 4 desk pads out of one side and still have some leftover. My side came in right at 19sqft, which makes it about $7.90/sqft. At that price, it puts the cost of my pad at $30.63. Not bad. Next was the backing. Since I was going to be putting this on top of my PowerPlay pad, I needed something under the leather to keep things level. I didn’t want a bump or indication of where the charging pad was. First step was to measure the thickness of the charging pad. According to my calipers, it came in at 2.3mm. I opted to go with some 2mm thick EVA foam. My local craft store (Michaels) had a roll of 36″x60″ for $9. Close enough. I also needed a way to adhere the two together. Looking through their glue, my options were limited for something that indicated that it bonded leather and foam. I ended up going with Gorilla Spray Adhesive for $13 as it indicated on the label that it could bond both materials.
The Build
I started by laying out the leather and making my cut lines. I used a long level and framing square to make sure I was cutting a proper rectangle as opposed to a rhombus or un-named yet to be discovered shape.
A 14″ x 36″ leather rectangle.
I used an X-Acto knife and put a cutting board beneath the leather while making the cuts. I cut from the top side of the leather to ensure that I had a nice clean edge (and it’s easier to mark). Next, I rolled out the foam and placed the leather on top to begin marking stuff out and ensure I had a decent margin.
I left myself 1/2″ on all sides of the leather and marked the position on the foam with a sharpie.
Next, I placed the charging pad to make sure it was positioned where I wanted it. I wanted it to be 1/2″ from the bottom, and 1/2″ from the right side of my pad. Above, you can see that there is more than 1/2″ because I also have a 1/2″ margin around where the edge of the leather will be.
At the top of the PowerPlay pad is the connector for the USB cable that also houses the LightSpeed dongle. This portion will protrude through the leather. I flipped the pad upside down and traced the hosing portion and cut it out.
I wanted to mask off the underside of the leather that would come into contact with the PowerPlay pad as I wanted it to sit on top of it, not be permanently bonded to it. I cut out a couple piece of paper to mask this off.
I covered a table outside with plastic and sprayed both pieces with the Gorilla Glue. There was a bit of a breeze, so I weighed down the paper mask using some quality weights.
With some help from my daughter, I laid the leather onto the foam while being careful to ensure that my cutouts lined up where they should have. I used a rubber J Roller to make sure that the leather was completely bonded to the foam.
Success. The desk is adequately covered, and the mouse charges through the leather just fine.
Conclusion
If you consider only the amount of materials that I used to make this, the build cost comes in at about $40. Not bad at all. Timewise, it was a rather light project taking about an hour to craft, most of which was planning out cuts and such before actually cutting. You may notice that there are a few wrinkles in the above photo. These will smooth out over time, and after setting a hot cup of coffee on the left side this morning, it is pretty much completely flat. I have to say, I’m pretty happy with the result.
Building a Raspberry Pi Powered Brewery Control Panel That Reports to Azure Log Analytics
The Why?
I’ve been home brewing for over 10 years. I got my start after helping a colleague brew on his system in his garage and jumped straight into an all-grain 3 vessel setup the next day. Well, not exactly the next day. It took me about a month to build my first system. I did what a lot of homebrewers do and used three 1/2 bbl kegs as brew pots with propane as the heat source. This system served me very well for those 10 years and is still fully functional today. But after 10 years of brewing in my garage, I decided it was finally time to upgrade some components, switch over to a fully electric setup, and brew in my basement where the temperature is 74℉ year round thanks to the server rack that sits in the corner. I’ve gone back and forth over the years leading up to the build as to whether or not to use a PLC of some sort, or a simple PID controlled setup. I really liked the simplicity of the PID controllers, however, the prospect of flexibility and future upgrade-ability eventually won me over and I decided to go with a Raspberry Pi powered solution. Since there are tons of articles around the net detailing how to build a panel, I’ll just touch on some of the bits without going into super detail on every aspect and instead focus on the Raspberry Pi and the code that runs everything.
My existing propane setup. Apart from adding a RIMS tube a few years ago, the setup is the same as the day I started brewing with it.
Build Objectives
For the build, there were a few things that I wanted:
• Full stainless
• Sanitary Fittings (Tri-Clover)
• DIN Rail mounted components
• 1/2 bbl (15 gal) batch size
• Ability to run both HLT and BK at the same time
Hardware
I’ve included a full build sheet at the bottom of this article that includes places that I purchased items from and prices. The main difference between this panel, and a PID controlled one comes down to just four components:
• Raspberry Pi
• Touchscreen
• Hats (expansion boards)
• Power Supplies
For the Raspberry Pi, I went with the 4GB model 4B. I figured that the additional memory couldn’t hurt, and since everything is part of the board, the only way to upgrade down the road is to completely replace the Pi. I also opted to go with a larger touchscreen than what I used for my Fermentation Controller build. Instead of the 7″, I chose a 10″ screen to allow for an easier to read (and control) interface. We will also need a 5v and 12v power supply to power the Pi and touchscreen.
For the hats, I opted to utilise the DAQC2plate and THERMOplate from Pi-Plates. With the fermentation controller build, I simply used a DAQCplate to do both the control and temperature measurement. One key difference between the DAQCplate and THERMOplate is that the DAQCplate does the temperature readings when you ask for them (which take about a second each), as opposed to the THERMOplate which does them in the background and then just returns the last read value when you request it. For a fermentation controller, waiting one second for each temperature measurement is no big deal as we aren’t making changes rapidly or drastically. For the brewing process, we need something a bit more responsive.
Layout
The front of the panel. Element controls on the left, pumps on the right. Master switch and E-Stop on the top row.
Back side of the front panel showing the switches and wires.
The interior of the panel
I wanted to keep the inside of my panel as tidy as possible. The DIN rails and cable raceways helped with that tremendously. The input is a 50A circuit which comes into a DPST relay (RLY1). From there, it is split to two 32A breakers (BRKR1 & 2) to ensure that a single element can’t pull more than that and to reduce down-stream wiring requirements. Each breaker feeds into a bank of terminal blocks to distribute the current to the various components on each leg. All of the 110v components (Relay coils and pumps) run off of a single breaker and phase. Two other relays (RLY2/3) are controlled via switches on the front panel to over-ride power to the heating elements. The transformers at the top power the Raspberry Pi, Pi-Plates, and Touchscreen.
Code
There are three parts to the code. The UI, the controller, and finally, the log writer. The UI is a fairly simple webpage. It makes use of css for the layout, and javascript to update the elements. PHP powers the back end to generate the responses for the AJAX calls. The controller is a python script which monitors the temperature of various components, controls the SSRs and heatsink fans, and writes metrics to a file that is used to update the UI and send data to Azure. All of the code for this is posted to my github repository.
UI
1. Hot Liquor Tank SSR Heatsink Temperature – Monitored using a LM35DZ chip.
2. CPU Temperature – pulled via the gpiozero python module
3. Boil Kettle SSR Heatsink Temperature – Monitored using an LM35DZ chip.
4. HLT Set Value – When in AUTO Mode, the controller will attempt to maintain the indicated temperature +/- the value of the Hysteresis.
5. HLT Process Value – The value currently read from the DS18B20 probe in the HLT.
6. Mash Tun SV – Currently, this is only used to toggle the color of the background of the MT temperature. Should I add more advanced logic or automation in the future, this can be used to control more of the process.
7. MT PV – This is fed by another DS18B20 probe just like the HLT, only in the MT.
8. BK SV – In this instance, the Set Value is indicated by a percentage. Instead of using temperature to control the heating element, we simply run it for a portion of the interval (in this case, 50%). The interval length can be configured to adjust the length of time the element is on or off.
9. BK PV – Another DS18B20, only this one is in the… wait for it… Boil Kettle.
10. HLT Mode – This can be toggled between AUTO or Temperature Mode, and MAN or Manual mode. Auto mode is controlled based on the temperature and hysteresis to determine whether the element is on or off.
11. BK Mode – Same as #10, but for the BK.
12. Total Runtime – How long the controller has been running (HH:mm:ss)
13. UI Refresh – Allows the UI to be force refreshed at will.
14. Toggles the Log Analytics Ingstion on or off.
15. Toggles the Temperature controller on or off.
16. Config.
1. HLT Cycle – How many seconds between each evaluation of the temperature to determine whether or not the element should
2. HLT Delta (Hysteresis). If the Pv is above or below the Sv by more than the Hysteresis, the element is cycled on or off.
3. MT Delta
4. BK Cycle Time
5. BK Delta
6. Shutdown System
7. Restart System
8. Cancel
9. Confirm
azure.py
The azure.py script is what sends the data to Log Analytics. It consists of 4 main portions. The settings are loaded by reading the conf.json file and reading the WorkspaceId, WorkspaceKey, and LogName parameters. The WorkspaceId is the guid for the Log Analytics workspace. The Key is either the primary or secondary key. The keys and workspace ID can all be found under Agent Management (formerly advanced settings). LogName is the name of the log that will show up in Log Analytics. Like all other custom log sources, ‘_CL’ will be automatically appended to the end of whatever name you use. Our first function builds the signature to authenticate our POST requests.
def build_signature(customer_id, shared_key, date, content_length, method, content_type, resource):
x_headers = 'x-ms-date:' + date
string_to_hash = method + "\n" + str(content_length) + "\n" + content_type + "\n" + x_headers + "\n" + resource
bytes_to_hash = bytes(string_to_hash).encode('utf-8')
decoded_key = base64.b64decode(shared_key)
encoded_hash = base64.b64encode(hmac.new(decoded_key, bytes_to_hash, digestmod=hashlib.sha256).digest())
authorization = "SharedKey {}:{}".format(customer_id,encoded_hash)
return authorization
The build signature function takes a few parameters. All of the parameters are passed to it by the next function. build_signature will build a SHA256 hash based on our keys, the date and time (RFC 1123 format), and the length of the content being passed. This allows us to generate a 1-way hash that can be used by Azure to authenticate the payload once it arrives without having to pass our key.
def post_data(customer_id, shared_key, body, log_type):
method = 'POST'
content_type = 'application/json'
resource = '/api/logs'
rfc1123date = datetime.datetime.utcnow().strftime('%a, %d %b %Y %H:%M:%S GMT')
content_length = len(body)
signature = build_signature(customer_id, shared_key, rfc1123date, content_length, method, content_type, resource)
uri = 'https://' + customer_id + '.ods.opinsights.azure.com' + resource + '?api-version=2016-04-01'
headers = {
'content-type': content_type,
'Authorization': signature,
'Log-Type': log_type,
'x-ms-date': rfc1123date
}
response = requests.post(uri,data=body, headers=headers)
post_data is the function that we interact with directly to send the information to Azure. It will call build_signature and form the payload. It takes our Workspace ID, Workspace Key, Body (JSON formated string), and name of the log. Since we store our data or payload in JSON format, we don’t have to do much else other than read the json file and pass it along.
def OnKill(signum, frame):
global run
run = False
signal.signal(signal.SIGINT, OnKill)
signal.signal(signal.SIGTERM, OnKill)
This is our exit handler. Since the script runs in the background and we don’t directly interact with it, we need a way to tell it to exit and what to do when we tell it to do so. We use the signal library to handle these. First we define our function that gets called (OnKill) and then we register handlers to call it depending on which type of signal was sent to the application. The first registers it to handle “INT” signals. In our case, this would be like hitting Ctrl+C from an SSH terminal to kill the running application or using kill -2 <pid>. The second intercepts “TERM” signals or kill -15 <pid>. If either of these signals is sent to our program, tell our program to set the run variable to false which causes our loop in the next code block to stop looping.
while run:
try:
#Read Current Data Points
f = open('/var/www/html/py/data.json', 'r')
data = json.load(f)
f.close()
body = json.dumps(data)
post_data(customer_id, shared_key, body, log_type)
except Exception as e:
now = datetime.datetime.now()
print(e)
f = open('/var/www/html/python_errors.log', 'a')
f.write("%s - AZURE [%i] - %s\n" % (now.strftime("%Y-%m-%d %H:%M:%S"), sys.exc_info()[-1].tb_lineno, e))
f.close()
time.sleep(LoopDelay)
This loop will continue to run as long as run is set to True. If we receive one of the signals mentioned earlier (SIGINT or SIGTERM) we set run to False and kill the loop. The loop is simple. It pulls the latest data from the data.json file and passes it as the payload to Log Analytics using the REST API. Our data.json file looks like this:
{
"MtAuto": 152,
"HltAuto": 130,
"BkStatus": 0,
"BkMode": "M",
"HltStatus": 1,
"HltHsTemp": 25.93,
"BkAuto": 8.7,
"MtTemp": 66.65,
"HltDelta": 1,
"BkTemp": 66.988,
"MtDelta": 1,
"HltMan": 50,
"BkMan": 50,
"CpuTemp": 46.738,
"BkHsTemp": 25.88,
"HltCycle": 3,
"BkCycle": 5,
"HltTemp": 66.313,
"HltMode": "A",
"BkDelta": 1
}
This is the data that we pass to Log Analytics which can then be queried. In the below example, we pull a count of all entries where the measured HLT Temp was higher than the set point + delta and bin it in 5 minute intervals. These would be periods where we overshoot our temps.
BrewController_CL
| where HltTemp > (HltAuto + HltDelta)
| summarize count() by bin(TimeGenerated, 5m)
If you’re thinking to yourself that the azure code looks familiar, yes, it probably does. It’s the code that’s available on the Azure Monitor Data Collector API page. I’m using the python 2 version of the code.
tempcontrol.py
The temp control script is where most of the magic happens. This is where we read our sensor data, act on it (if needed) and write the data to a file for the UI or Azure script to ingest and process.
while run:
currTime = round(time.time(), 1)
#Update existing values
if UpdateTemps:
#Load Data
f = open('/var/www/html/py/data.json', 'r')
data = json.load(f)
f.close()
#Update Data
data['HltHsTemp'] = GetHeatsink(0)
data['CpuTemp'] = GetCPU()
data['BkHsTemp'] = GetHeatsink(1)
data['HltTemp'] = THERMO.getTEMP(0,11)
data['MtTemp'] = THERMO.getTEMP(0,10)
data['BkTemp'] = THERMO.getTEMP(0,9)
UpdateTemps = False
#Update Uptime File
f = open('/var/www/html/py/uptime', 'w')
f.write(str(currTime - startTime))
f.close()
#Check for Updated Targets
#Mode
if os.path.exists('/var/www/html/py/mode.json'):
f = open('/var/www/html/py/mode.json', 'r')
NewData = json.load(f)
f.close()
if NewData['Target'] == 'hlt':
data['HltMode'] = NewData['NewMode']
elif NewData['Target'] == 'bk':
data['BkMode'] = NewData['NewMode']
os.remove('/var/www/html/py/mode.json')
#Temp
if os.path.exists('/var/www/html/py/temp.json'):
f = open('/var/www/html/py/temp.json', 'r')
NewData = json.load(f)
f.close()
if NewData['Target'] == 'hlt' and NewData['Mode'] == 'a':
data['HltAuto'] = NewData['Value']
elif NewData['Target'] == 'hlt' and NewData['Mode'] == 'm':
data['HltMan'] = NewData['Value']
elif NewData['Target'] == 'mt' and NewData['Mode'] == 'a':
data['MtAuto'] = NewData['Value']
elif NewData['Target'] == 'bk' and NewData['Mode'] == 'a':
data['BkAuto'] = NewData['Value']
elif NewData['Target'] == 'bk' and NewData['Mode'] == 'm':
data['BkMan'] = NewData['Value']
os.remove('/var/www/html/py/temp.json')
#Settings
if os.path.exists('/var/www/html/py/settings.json'):
f = open('/var/www/html/py/settings.json', 'r')
NewData = json.load(f)
f.close()
data['HltCycle'] = NewData['HltCycle']
data['HltDelta'] = NewData['HltDelta']
data['MtDelta'] = NewData['MtDelta']
data['BkCycle'] = NewData['BkCycle']
data['BkDelta'] = NewData['BkDelta']
os.remove('/var/www/html/py/settings.json')
else:
UpdateTemps = True
#HLTControl
if data['HltMode'] == 'A':
HLTOn = ActionCount + 1
if data['HltTemp'] < (data['HltAuto'] - data['HltDelta']):
TurnHLTOn()
else:
TurnHLTOff()
else:
if HLTOn == ActionCount:
TurnHLTOn()
HltCycleLen = data['HltCycle'] * 2
HLTOn = ActionCount + HltCycleLen
HLTOff = ActionCount + ((float(data['HltMan']) / 100) * HltCycleLen)
if HLTOff == ActionCount:
TurnHLTOff()
elif HLTOn < ActionCount and HLTOff < ActionCount:
HLTOn = ActionCount + 1
#BKControl
if data['BkMode'] == 'A':
BKOn = ActionCount + 1
if data['BkTemp'] < (data['BkAuto'] - data['BkDelta']):
TurnBKOn()
else:
TurnBKOff()
else:
if BKOn == ActionCount:
TurnBKOn()
BkCycleLen = data['BkCycle'] * 2
BKOn = ActionCount + BkCycleLen
BKOff = ActionCount + ((float(data['BkMan']) / 100) * BkCycleLen)
if BKOff == ActionCount:
TurnBKOff()
elif BKOn < ActionCount and BKOff < ActionCount:
BKOn = ActionCount + 1
ActionCount += 1
#Save Data
f = open('/var/www/html/py/data.json', 'w')
json.dump(data, f)
f.close()
#Sleep
time.sleep(0.5)
except Exception as e:
now = datetime.now()
print(e)
f = open('/var/www/html/python_errors.log', 'a')
f.write("%s - TEMP CONTROL [%i] - %s\n" % (now.strftime("%Y-%m-%d %H:%M:%S"), sys.exc_info()[-1].tb_lineno, e))
f.close()
We start with reading the temp probe data starting on line 5. Since our DS18B20 probes only update once per second, and our loop runs every 1/2 second, there is no need to update them every loop. We use a simple bool flag to run this portion of code every other loop. Next, we check our HLT and BK to determine whether to cycle them on, off, or do nothing. If we’re in automatic mode, we check the current temp (Pv) and compare it against the target temp (Sv) and hysteresis (Delta). If Pv < (Sv – Delta) then we turn the element on. If not, we turn it off. On a true PID controller, the element might remain on longer in order to stabilise the temperature and reduce the variance. So far, I’ve found that I haven’t needed the more advanced logic of a true PID controller to keep my temps where I need them, so I’ve opted to keep things simple. I may end up switching it to PID logic should I find that not the case, but the first couple batches that I’ve done on the system have been really good. If the elements are in manual mode, we take a look at the cycle length, compare it to on percentage and calculate the number of loops the element should be on and off. We then set each into a variable that tells it when to turn on.
Azure Monitor Workbook
So, we’re brewing beer and putting data into Azure. How do we use that data? I have a TV in my brew area that I pull the workbook up on on brew day. This allows me to monitor data and trends and make adjustments whether it be for that brew session, or the next one.
Our Brewery Controller workbook
What does this mean?
I’ve marked a few points on the image above which show some interesting points in our brew day.
1. You can see the blue line on the HLT graph set to our strike temperature which was 165℉ for this recipe. You can also see the greenish line that indicates that actual temperature of the water. For this, I was heating around 18 Gal of water from room temp (about 68℉) to our strike temperature.
2. At point 2, we hit our strike temp and can perform our mash in. You’ll notice that a few minutes after we hit temp, it plumets to around 130℉ and then starts to rise again. After I mashed in, I added another 5 Gal of water to the HLT to ensure I had enough for mash out/sparge. Since the water I added was also at room temp, it dropped the temperature of the HLT down which then gets heated back up. You’ll also notice that I reduced the set point of the HLT at this time. I make use of a HERMS coil to maintain mash temperatures, so once mashing in is taken care of, I set the temperature of my HLT to whatever temperature I want my mash to be and then re-circulate it through the HERMS (pictures below).
3. The area around point 3 is where I ran into a problem. Some of the rice hulls that I was using as a filter bed got sucked into the hoses. It took me a while to figure out what was going on. The sprayer that I was using to evenly distribute water across the top of the grain bed got clogged by the rice hulls. Water was still coming out, but it wasn’t re-circulating enough water to affect the mash temperature. I swapped out the end of my re-circulation sprayer with a different style which included a larger opening. Once in place, temperatures were back where I wanted them.
4. Number 4 is where I performed my mash out. I raised to the HLT temp to 168℉ to halt conversion and began sparging. The point where the temperature starts to drop is the point that I shut the element override off from the switch on the control panel. The controller doesn’t see this which is why we have a divergence from the set value and process value.
5. Point 5 is where I added and heated up some additional water to use for cleaning.
6. Point 6 calls out the light blue lines. These are used to indicate when the element is “on” as far as the controller is concerned. On the HLT it’s pretty easy to see the periods where the element is on and off. On the BK, it’s a bit more condensed since it’s in manual mode and automatically firing quite rapidly. I have found so far that with a 5 second cycle length and the element on 50%, I can maintain a nice boil without boiling over.
7. You’ll notice at Point 7, there is a sharp hook, a dip, and then a climb before it levels off. Before this point, I had my element set to something like 75% or 80%. This was a bit too aggressive and caused a near boil-over. The spike is the point where I turned the BK override off, made some adjustments, and turned it back on.
Dashboard Template
{
"version": "Notebook/1.0",
"items": [
{
"type": 9,
"content": {
"version": "KqlParameterItem/1.0",
"parameters": [
{
"id": "ee40ef7f-bcea-4d1c-a3da-fca1355319cd",
"version": "KqlParameterItem/1.0",
"name": "TimeRange",
"label": "Time Range",
"type": 4,
"isRequired": true,
"value": {
"durationMs": 43200000,
"endTime": "2020-12-27T01:35:00.000Z"
},
"typeSettings": {
"selectableValues": [
{
"durationMs": 300000
},
{
"durationMs": 900000
},
{
"durationMs": 1800000
},
{
"durationMs": 3600000
},
{
"durationMs": 14400000
},
{
"durationMs": 43200000
},
{
"durationMs": 86400000
}
],
"allowCustom": true
},
"timeContext": {
"durationMs": 86400000
}
},
{
"id": "9c69ebb2-0553-43b3-9662-162cd0a650b0",
"version": "KqlParameterItem/1.0",
"name": "FocusTime",
"label": "Focused Time (min)",
"type": 1,
"isRequired": true,
"value": "10",
"typeSettings": {
"paramValidationRules": [
{
"regExp": "[\\d]*",
"match": true,
"message": "Must be a Number"
}
]
},
"timeContext": {
"durationMs": 86400000
}
}
],
"style": "pills",
"queryType": 0,
"resourceType": "microsoft.operationalinsights/workspaces"
},
"name": "parameters - 5"
},
{
"type": 3,
"content": {
"version": "KqlItem/1.0",
"query": "BrewDay_CL\r\n| top 1 by TimeGenerated\r\n| extend Title = \"Last Message:\"\r\n| project TimeGenerated, Title",
"size": 4,
"timeContext": {
"durationMs": 43200000,
"endTime": "2020-12-27T01:35:00.000Z"
},
"timeContextFromParameter": "TimeRange",
"queryType": 0,
"resourceType": "microsoft.operationalinsights/workspaces",
"visualization": "tiles",
"tileSettings": {
"titleContent": {
"columnMatch": "Title"
},
"leftContent": {
"columnMatch": "TimeGenerated",
"formatter": 6
},
"showBorder": false,
"size": "full"
}
},
"name": "query - 4"
},
{
"type": 3,
"content": {
"version": "KqlItem/1.0",
"query": "BrewDay_CL\r\n| project TimeGenerated, HltAuto_d, HltMan_d, OnOff = HltStatus_d * 100, HltTemp_d, HltCycle_d, HltDelta_d",
"size": 0,
"aggregation": 5,
"showAnalytics": true,
"title": "Hot Liquor Tank",
"timeContext": {
"durationMs": 43200000,
"endTime": "2020-12-27T01:35:00.000Z"
},
"timeContextFromParameter": "TimeRange",
"queryType": 0,
"resourceType": "microsoft.operationalinsights/workspaces",
"visualization": "linechart"
},
"customWidth": "33",
"showPin": true,
"name": "HltOverall"
},
{
"type": 3,
"content": {
"version": "KqlItem/1.0",
"query": "BrewDay_CL\r\n| where (TimeGenerated > {TimeRange:start}) and (TimeGenerated < {TimeRange:end})\r\n| project TimeGenerated, MtAuto_d, MtTemp_d, MtDelta_d",
"size": 0,
"showAnalytics": true,
"title": "Mash Tun",
"timeContext": {
"durationMs": 43200000,
"endTime": "2020-12-27T01:35:00.000Z"
},
"timeContextFromParameter": "TimeRange",
"queryType": 0,
"resourceType": "microsoft.operationalinsights/workspaces",
"visualization": "linechart"
},
"customWidth": "33",
"showPin": true,
"name": "MtOverall"
},
{
"type": 3,
"content": {
"version": "KqlItem/1.0",
"query": "BrewDay_CL\r\n| project TimeGenerated, BkAuto_d, BkMan_d, OnOff = BkStatus_d * 100, BkTemp_d, BkCycle_d, BkDelta_d",
"size": 0,
"aggregation": 5,
"showAnalytics": true,
"title": "Boil Kettle",
"timeContext": {
"durationMs": 43200000,
"endTime": "2020-12-27T01:35:00.000Z"
},
"timeContextFromParameter": "TimeRange",
"queryType": 0,
"resourceType": "microsoft.operationalinsights/workspaces",
"visualization": "linechart"
},
"customWidth": "33",
"showPin": true,
"name": "BkOverall"
},
{
"type": 3,
"content": {
"version": "KqlItem/1.0",
"query": "BrewDay_CL\r\n| where TimeGenerated > ago({FocusTime:value}m)\r\n| project TimeGenerated, HltAuto_d, HltMan_d, OnOff = HltStatus_d * 100, HltTemp_d, HltCycle_d, HltDelta_d",
"size": 0,
"title": "Hot Liquor Tank - Last {FocusTime:value} min",
"queryType": 0,
"resourceType": "microsoft.operationalinsights/workspaces",
"visualization": "linechart"
},
"customWidth": "33",
"name": "HltFocused"
},
{
"type": 3,
"content": {
"version": "KqlItem/1.0",
"query": "BrewDay_CL\r\n| where TimeGenerated > ago({FocusTime:value}m)\r\n| project TimeGenerated, MtAuto_d, MtTemp_d, MtDelta_d",
"size": 0,
"title": "Mash Tun - Last {FocusTime:value} min",
"queryType": 0,
"resourceType": "microsoft.operationalinsights/workspaces",
"visualization": "linechart"
},
"customWidth": "33",
"name": "MtFocused"
},
{
"type": 3,
"content": {
"version": "KqlItem/1.0",
"query": "BrewDay_CL\r\n| where TimeGenerated > ago({FocusTime:value}m)\r\n| project TimeGenerated, BkAuto_d, BkMan_d, OnOff = BkStatus_d * 100, BkTemp_d, BkCycle_d, BkDelta_d",
"size": 0,
"title": "Boil Kettle - Last {FocusTime:value} Min",
"queryType": 0,
"resourceType": "microsoft.operationalinsights/workspaces",
"visualization": "linechart"
},
"customWidth": "33",
"name": "BkLastFive"
},
{
"type": 3,
"content": {
"version": "KqlItem/1.0",
"query": "BrewDay_CL\r\n| project TimeGenerated, Target=HltAuto_d, Temperature=HltTemp_d, Manual=HltMan_d",
"size": 0,
"aggregation": 5,
"showAnalytics": true,
"title": "Hot Liquor Tank",
"timeContext": {
"durationMs": 172800000
},
"queryType": 0,
"resourceType": "microsoft.operationalinsights/workspaces",
"visualization": "linechart",
"chartSettings": {
"seriesLabelSettings": [
{
"seriesName": "Target",
"color": "blue"
},
{
"seriesName": "Temperature",
"color": "turquoise"
},
{
"seriesName": "Manual",
"color": "greenDark"
}
]
}
},
"showPin": true,
"name": "query - 8"
},
{
"type": 3,
"content": {
"version": "KqlItem/1.0",
"query": "BrewDay_CL\r\n| project TimeGenerated, Target=MtAuto_d, Temperature=MtTemp_d",
"size": 0,
"aggregation": 5,
"showAnalytics": true,
"title": "Mash Tun",
"timeContext": {
"durationMs": 172800000
},
"queryType": 0,
"resourceType": "microsoft.operationalinsights/workspaces",
"visualization": "linechart",
"chartSettings": {
"seriesLabelSettings": [
{
"seriesName": "Target",
"color": "redBright"
},
{
"seriesName": "Temperature",
"color": "yellow"
}
]
}
},
"showPin": true,
"name": "query - 9"
},
{
"type": 3,
"content": {
"version": "KqlItem/1.0",
"query": "BrewDay_CL\r\n| project TimeGenerated, Target = BkAuto_d, Temperature = BkTemp_d, Manual = BkMan_d",
"size": 0,
"aggregation": 5,
"showAnalytics": true,
"title": "Boil Kettle",
"timeContext": {
"durationMs": 172800000
},
"queryType": 0,
"resourceType": "microsoft.operationalinsights/workspaces",
"visualization": "linechart",
"chartSettings": {
"seriesLabelSettings": [
{
"seriesName": "Target",
"color": "purple"
},
{
"seriesName": "Temperature",
"color": "green"
},
{
"seriesName": "Manual",
"color": "blue"
}
]
}
},
"showPin": true,
"name": "query - 10"
}
],
"fallbackResourceIds": [
"/subscriptions/<SUBSCRIPTIONID>/resourcegroups/<RESOURCEGROUP>/providers/Microsoft.OperationalInsights/workspaces/<WORKSPACENAME>"
],
"$schema": "https://github.com/Microsoft/Application-Insights-Workbooks/blob/master/schema/workbook.json"
}
You’ll need to replace <SUBSCRIPTIONID>, <RESOURCEGROUP>, and <WORKSPACENAME> with appropriate values should you want to utilize this in your environment. From a data standpoint, I’ve found that a single brew day uses less than 200KB of quota. Even if you brew every day, you’ll likely never exceed the 5GB of free usage to incur a charge (based on current pricing plans as of 2021-01-01).
Brewery Pictures
This is the finished result. From left to right, HLT, MT, BK. Two pumps (March 809’s with Center Inlet TC Conversion heads from brewershardware.com and the plate chiller from my old setup with the connection fittings swapped to TC. For the pumps, I found that I was able to remove the nuts that hold the top of the table on, and use couplers and some stainless M6 threaded rod to create a “shelf” for the pumps to attach to. This allowed me to attach the pumps and chiller without drilling into or permanently altering the table.
This is the inside of my HLT. You can see the stainless wavy element below the HERMS coil. I ended up going with a 3 coil parallel one from brewpi. This reduces the height of the coil while keeping the surface area of a larger coil. The reduced height allows me to keep it submerged with substantially less water.
The inside of the Mash Tun. False bottom on the…. bottom.
This is what I’ve devised for a sparge arm/recirc arm. It’s a center pickup from Spike that I took a bit of the stainless that I cut from the control panel and fashioned a little flapper thing to spread the water over the top. The rubber band currently holds the flapper on. I may try to use some sort of a screw or something in the side to hold it up, but my machining capabilities for metal are a bit limited.
Build Costs & Parts List
The total cost of the build wasn’t actually as bad as I thought it might have been. The panel ended up a just over $1,600 and the brewery itself was just over $4,100. Those prices do not include shipping, but for most items, shipping was free. I would add probably another $100 to the overall total for shipping from places that it wasn’t free. The build sheet can be found on my OneDrive. There are two separate tabs; one for the panel, and one for the brewery. On the brewery side of things, there were many pieces of equipment that I already had from my last brewery, so this is not a comprehensive list for everything you need if you have nothing (things like hydrometers, scales, grain mill, etc). All of the source code is on my GitHub.
Thanks
I’d like to give a special thanks to a few people.
• Mike Cymerman from Spike Brewing who helped with the design and port locations for the custom kettles.
• Jerry Wasinger from Pi-Plates who helped troubleshoot some of the initial issues I ran into getting the code working for the THERMOplate.
• Matt Dunlop for drinking with me and keeping me company on my first brew day with the new system and telling me it was cool.
Using an App Registration to Query Log Analytics via Power BI
Power BI is a great tool to visualize data and create effective interactive dashboards and reports. Log Analytics is great to gather and correlate data. Naturally, the two are a great pair. While there isn’t yet a native connector for Log Analytics, you can still pull data by writing a custom M Query in Power BI. Thankfully, with just a couple clicks from Log Analytics, it will generate everything for you so that you don’t need to know M Query to pull data. When doing this, you’ll need to login to Azure using an Organization Account or another interactive login method. But what if you need to have a report that doesn’t require you to login every time? Using an App Registration and authenticating via OAuth can accomplish this, but how do we do that in PowerBI?
Security Disclaimer
The method that I’m going to show you stores the API Key in the dataset/query. This is meant as more of a PoC than something that you would use in any sort of a production environment unless you can protect that data. If you’re putting this report on a PowerBI server, you’ll want to make sure people cannot download a copy of the report file as that would allow them to obtain the API key.
Setup
Before we try to query Log Analytics from Power BI with OAuth, we need to setup an App Registration.
1. Log into Azure and open App Registrations either from the main portal or via Azure Active Directory. Click on the New Registration button, give it a name and a Redirect URI.
2. Next, generate a new client secret.
Be sure to make note of the client secret as it can not be retrieved once you leave this page.
3. Now we need to grant access to the Log Analytics API (Data.Read). To do this, click Add Permission select “APIs my Organization Uses” and search for Log Analytics.
Be sure to select Application Permissions.
Once you’ve added the permission, you need to grant admin consent to the API to interact on the users behalf.
We now have the App Registration almost ready to go. What we’ve done is grant the App Registration the ability to query the Log Analytics API. What we haven’t don yet is grant it access to our Log Analytics workspaces. We’ll take care of that next.
4. Browse to your Log Analytics workspace. We’ll need to add our App Registration to the Log Analytics Reader role. This will grant allow the App Registration the ability to query any table within this workspace. If you want to limit the tables that the app registration is able to query, you will need to define a custom role and assign them to that role instead. I won’t cover creating a custom role in this post, but you can read about how to create a custom role here and see a list of all the possible roles here. You may also want to read through this article to read about the schema for the JSON file that makes up each custom role.
5. Now that the permissions have been granted, let’s run a query. Once you have some results, click on Export and then Export to Power BI (M query). This will download a text file that contains the query. Go ahead an open it up.
The text file will look something like this. If we were to put this into Power BI as is, we could get our data after authenticating with our Organization Account. We’ll take the output and customize it just a bit.
let AnalyticsQuery =
let Source = Json.Document(Web.Contents("https://api.loganalytics.io/v1/workspaces/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/query",
[Query=[#"query"="Usage
| where TimeGenerated > ago(1d)
",#"x-ms-app"="OmsAnalyticsPBI",#"prefer"="ai.response-thinning=true"],Timeout=#duration(0,0,4,0)])),
TypeMap = #table(
{ "AnalyticsTypes", "Type" },
{
{ "string", Text.Type },
{ "int", Int32.Type },
{ "long", Int64.Type },
{ "real", Double.Type },
{ "timespan", Duration.Type },
{ "datetime", DateTimeZone.Type },
{ "bool", Logical.Type },
{ "guid", Text.Type },
{ "dynamic", Text.Type }
}),
DataTable = Source[tables]{0},
Columns = Table.FromRecords(DataTable[columns]),
ColumnsWithType = Table.Join(Columns, {"type"}, TypeMap , {"AnalyticsTypes"}),
Rows = Table.FromRows(DataTable[rows], Columns[name]),
Table = Table.TransformColumnTypes(Rows, Table.ToList(ColumnsWithType, (c) => { c{0}, c{3}}))
in
Table
in AnalyticsQuery
6. Using OAuth is a two step approach. This is commonly known as Two-Legged OAuth where we first retrieve a token, and then use that token to execute our API calls. To get the token, add the following after the first line:
let ClientId = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
ClientSecret = Uri.EscapeDataString("xxxxxxxxxxxxx"),
AzureTenant = "xxxxxx.onmicrosoft.com",
LogAnalyticsQuery = "Usage
| where TimeGenerated > ago(1d)
",
OAuthUrl = Text.Combine({"https://login.microsoftonline.com/",AzureTenant,"/oauth2/token?api-version=1.0"}),
Body = Text.Combine({"grant_type=client_credentials&client_id=",ClientId,"&client_secret=",ClientSecret,"&resource=https://api.loganalytics.io"}),
OAuth = Json.Document(Web.Contents(OAuthUrl, [Content=Text.ToBinary(Body)])),
This bit will setup and fetch the token. I’ve split out the Log Analytics query to make it easier to reuse the bit of code for additional datasets. Obviously, you’ll want to put your ClientId, ClientSecret, and Azure Tenant on the first three lines. After that, you’ll want to edit the source line. Change it from:
let Source = Json.Document(Web.Contents("https://api.loganalytics.io/v1/workspaces/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/query",
[Query=[#"query"="Usage
| where TimeGenerated > ago(1d)
",#"x-ms-app"="OmsAnalyticsPBI",#"prefer"="ai.response-thinning=true"],Timeout=#duration(0,0,4,0)])),
to something like this:
Source = Json.Document(Web.Contents("https://api.loganalytics.io/v1/workspaces/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/query",
[Query=[#"query"=LogAnalyticsQuery,#"x-ms-app"="OmsAnalyticsPBI",#"prefer"="ai.response-thinning=true"],Timeout=#duration(0,0,4,0),Headers=[#"Authorization"="Bearer " & OAuth[access_token]]])),
You may notice that we did two things. First, we changed the query to use our variable instead of the text itself. This is done purely to make it easier to re-use the code for additional datasets. The other thing we’ve done is add the Authorization header to the request using the token we obtained from the OAuth line. You should now have something like this:
let AnalyticsQuery =
let ClientId = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
ClientSecret = Uri.EscapeDataString("xxxxxxxxxxxxx"),
AzureTenant = "xxxxxx.onmicrosoft.com",
LogAnalyticsQuery = "Usage
| where TimeGenerated > ago(1d)
",
OAuthUrl = Text.Combine({"https://login.microsoftonline.com/",AzureTenant,"/oauth2/token?api-version=1.0"}),
Body = Text.Combine({"grant_type=client_credentials&client_id=",ClientId,"&client_secret=",ClientSecret,"&resource=https://api.loganalytics.io"}),
OAuth = Json.Document(Web.Contents(OAuthUrl, [Content=Text.ToBinary(Body)])),
Source = Json.Document(Web.Contents("https://api.loganalytics.io/v1/workspaces/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/query",
[Query=[#"query"=LogAnalyticsQuery,#"x-ms-app"="OmsAnalyticsPBI",#"prefer"="ai.response-thinning=true"],Timeout=#duration(0,0,4,0),Headers=[#"Authorization"="Bearer " & OAuth[access_token]]])),
TypeMap = #table(
{ "AnalyticsTypes", "Type" },
{
{ "string", Text.Type },
{ "int", Int32.Type },
{ "long", Int64.Type },
{ "real", Double.Type },
{ "timespan", Duration.Type },
{ "datetime", DateTimeZone.Type },
{ "bool", Logical.Type },
{ "guid", Text.Type },
{ "dynamic", Text.Type }
}),
DataTable = Source[tables]{0},
Columns = Table.FromRecords(DataTable[columns]),
ColumnsWithType = Table.Join(Columns, {"type"}, TypeMap , {"AnalyticsTypes"}),
Rows = Table.FromRows(DataTable[rows], Columns[name]),
Table = Table.TransformColumnTypes(Rows, Table.ToList(ColumnsWithType, (c) => { c{0}, c{3}}))
in
Table
in AnalyticsQuery
Let’s put that into our query in Power BI. Open Power BI, create a new Blank Query and open the Advanced Editor.
Paste your query and make sure that there are no syntax errors.
One last thing we will need to do is set our Authentication method to Anonymous. You should be prompted to do so after clicking done, but if not, or you got click happy and dismissed it, you can click on Data Source Settings -> Edit Permissions. If you already have other data sources in your report, be sure to select the one that we just created and change the credentials to Anonymous.
We should now have a preview of our data
Now, if we need to add additional queries, it’s as simple as duplicating the dataset and changing the LogAnalyticsQuery variable on that dataset to the new query.
Building an Azure Connected Fermentation Monitor – Part 1 – The Hardware
Process control is one of the most important aspects of brewing. Sure, I’ve had some great beers that were brewed by people just flopping stuff into a pot. However, without process control, the results are not consistently repeatable. When we talk about process control in brewing, we are usually talking about temperature. Temperature is really everything in beer making and, all else the same, can produce very distinct beers. Temperature can affect just about every characteristic of a batch of beer such as fermentability, mouth feel, flavors, aromas, etc. In this blog post, I’m going to focus on temperature during fermentation and building a controller to do just that. I am going to focus on the hardware here and will do a follow-up post with details about the software. The software that I wrote for this is available on my GitHub space.
How it Works
The fermentation controller works by regulating the temperature during, well, fermentation. There are two outputs on the device, one for a heat source, and one for a cold source. For the cold source, I have a large chest freezer that is large enough to hold four 6 gallon carboys, or a single 60L Spiegel fermenter. When I need to drop the temperature, I trigger the freezer to turn on. Heat is provided using a 100w ceramic reptile bulb. These produce heat, but no light. This is perfect for our use as that’s what we want, heat, no light. By placing everything in a chest freezer, we have a built in cold source, it blocks out light, and it’s insulated so it holds temperature (hot or cold) really well. I’ve been using a Tilt Hydrometer for quite some time along with either their mobile app, or just a Raspberry Pi in a case that I could connect to for viewing the data. With this though, I wanted to have a touchscreen to interact with it and view data or, check on the fermentation away from home.
Parts List
First thing we want to do is gather all of the components that we’ll need for our build. I’ve listed everything out here along with where I bought them and price at time of purchase. There’s a link to the spreadsheet below.
All the parts laid out
• 14″x11″x5″ Waterproof NEMA Enclosure
• 4.7k 1/2w Resistor
• 5v Power Supply
• Waterproof DS18B20 Temp Sensor
• Standoffs
• Data Aquisition Control Plate
• DAQC Case Plate
• LED Panel Indicator Lights
• 3x Extension Cords (two colors)
• Polycarbonate Buildplate
• Terminal Strip Blocks
• Waterproof Cable Glands
• Insulated Fork Spade Terminal Connectors
• 7″ Raspberry Pi Touchscreen
• Raspberry Pi 3b+
• 2x 20A Solid State Relay
• Voltage Sensor
• 3x 15A Clamp Style Current Sensor
• Waterproof USB (Not Pictured)
• Waterproof RJ45 (Not Pictured)
• SSR Heatsink (Not Pictured)
• Male XLR Panel Mount (Not Pictured)
• Female XLR Connector (Not Pictured)
• Tilt Hydrometer (Not Pictured)
Buy List – Total ~$550
The Build
Assembly starts with putting together the Raspberry Pi and DAQC Plate. Sensors and other items can be connected to the Raspberry Pi via the SPI header. The SPI header utilizes a 3.3v signal to determine state and communicate with connected devices. The Pi unfortunately does not have a built in ADC or Analog/Digital Converter. For this, we utilize the DAQC Plate by Pi-Plates to handle all of our sensors and take care of any analog to digital conversions we may need. Pi-Plates are stackable and have a ready built python library that we can use which makes it very attractive in our case. Now, we could also do this build using an arduino or other misc IoT type of board, however, Tilt comes with a ready-built Raspbian based image that is perfect for what we want to do and doesn’t require us to write our own Bluetooth functions.
7″ Touchscreen, Raspberry Pi 3B+, DAQC Plate, Case Plate
Above we have the touchscreen, the Pi, the DAQC Plate, and the Case Plate. The mounting holes on the DAQC plate do not line up with the ones on the Pi, so the Case Plate makes mounting a lot easier and helps protect the contacts and provide support for the hardware.
We start by mounting the first plate to the back of the Touchscreen. We then add a couple of the M2.5 standoffs to then attach the Raspberry Pi
Next, we mount the Pi using some M2.5 screws and connect the screens ribbon cable
We then add some longer standoffs and mount the DAQC Plate. In this photo, I have some of the brass standoffs that I purchased, But I later swapped them out for the PTFE ones that came with the Case Plate as they were just a little too long and I wanted a better mating at the SPI header.
This is what the screen looks like in its assembled form with the Case Plate cover in place.
The inside of the enclosure along with the included accessories.
First thing we’re going to need to do is trim the PC sheet to fit inside. This will act as a non-conductive base to mount all of our components to. It will also allow us to easily remove everything should we need to service something down the road.
A few cuts on the table saw and we have a nice fit with a little bit of space on the sides.
Here I’ve marked all of the standoffs that I will use to mount the PC Sheet to. The standoffs are all varying heights and diameters, but the ones that I colored with a blue sharpie are all the same height and diameter. The one in red protrudes a bit above the rest, so we’ll need to drill a larger hole to accommodate that one so that it doesn’t cause the PC to bend or possibly crack.
I placed the PC sheet inside and transferred the location of the standoffs using the same colors.
I drilled each of them out using a drill press. If you don’t have a drill press, you can use a hand drill, but be careful that you keep the drill steady as PC can be easy to crack.
After drilling, I placed the sheet into the enclosure and made sure everything fit up correctly. Now is the time to make adjustments if you need to.
I drew up a simple wiring diagram to get an idea for how everything would be connected before I started placing components. It’s typically good to have a plan for how things will connect as it can make placement easier if you know where your cables are going to have to go.
Before permanently mounting anything or drilling holes, I dry fit everything together to make sure I had room for everything for all of the components as well as the wires that would be run. The Pi does not mount to the backplate, but I wanted to make sure my components were spaced so that nothing would hit it when the cover was closed.
While the components were in place, I traced out their locations so that I could drill the holes for mounting.
First thing is to drill the mounting holes for the SSRs onto the heatsink. I use a centering punch here to help keep our drill bits from walking when we start to drill. I had a few heatsinks that measured about 9″ x 1″ x 3″ that I had salvaged from some old audio amplifiers many years ago. This project is probably the first (and likely only) time my stockpile of random bits of circuitry was helpful.
With the holes drilled we can tap them to receive our screws. I think I used either M4 or 10-24 screws here.
With the SSR’s mounted, I can mount the other bits to the base board
Last thing to mount is the voltage Sensor
Next, we move on to cutting out the front of the enclosure
After cleaning up the LED holes, I moved on to the hole for the display
These were cut out with a Jigsaw. When the blade is cool, it makes nice clean cuts. However, as the blade heats up, it starts to melt shavings instead of dumping them. If you’re patient, and let the blade cool before continuing to cut, you can avoid this. Patience, unfortunately, is a skill that I lack along with X-Ray vision and super human strength.
To mount the LCD, I use some of the scraps of PC to make strips that will clamp the screen to the front. I put a couple of those soft rubbery feet things on each to add a bit of tension and grip.
An inside look at the screen and LEDs after being mounted
And a view from the front.
Wiring starts with connecting the voltage sensor and 5v power supply. I used a slightly smaller gauge wire here since these two devices have a much lower draw and have their own fuse to prevent over drawing.
To supply power the the Pi and Screen, I took a couple of Micro-USB cables that I had laying around. These will both connect to the 5v power supply. I’m using twist-ties to keep the cables in place for now as I’ll be adding more and will swap them out for cable ties once all the wire is in place. I’ve also drilled and mounted the cable glands and male XLR connector on the bottom of the panel. I didn’t remember to take a picture of that though. I think the drinking started one or two pictures above this.
The red and black wires from the USB cables connect to our output terminals on the power supply
As with most components and sensors, some adjustment is needed out of the box to ensure that our outputs or signals are correct. We just needed to adjust this one a hair.
Before I went any further, I made sure that the Pi booted up and worked with the power supply.
Wiring continues as components are wired up and cables are routed. You can see my input wire in the lower right (black) as well as the two outputs (white) and XLR connector for the temp probe. For the input, I cut the female (receptacle) end off the black extension cord which left me with the plug on the other end that I can plug into the wall to power the unit. For the outputs, I cut about 12″ from the female end and used those as tails to plug the freezer into. The rest of the wire was removed from the outer jacket to wire the internal components.
Another quick boot to make sure we didn’t fry anything and to check our wiring.
Next we add the current sensors. One for the main, and one each for the cold and hot side.
Next, we connect the SSRs to the DAQC plate and wire up the XLR connector. We have to add our 4.7k ohm resistor here to get accurate readings.
Pictures can sometimes be hard to see what connects to what. Hopefully this illustrates it a little bit better. The SSRs connect to the digital outputs on the left. We need to use a jumper here between the first and second to last pin as a safety. Our current and voltage sensors (the signal pin at least) connect to our analog inputs in the lower left. Our temp sensor and the ground for everything except for the SSRs connect to the digital inputs on the lower right.
Remember how I said we have to adjust some components? This is the output from the voltage sensor. This *should* be a nice sine wave. This is an oscilloscope that my Uncle gave me over 20 years ago. I had never used it… Until Now. The only time my reluctance to throw anything away has come in handy.
After adjusting, we now have a clean wave and can take accurate measurements. This adjustment has to be done with the power on, so be careful doing this as you have exposed electrical components. Making contact with the wrong part could damage your equipment or you.
I wrote up a quick python script to check the voltage and amperages. We’re getting readings, although the amperage is off.
Our completed build. S = Set or Target Temperature, V = Value or Current reading, G = Gravity, Delta is the amount above or below the set temperature the unit trigger the cold or heat.
Setting the target temperature
Other setting adjustments along with the ability to reboot or power off the device.
Now you might be wondering about how I got the screen to look the way it does. That’ll be covered in my next blog post, but I have uploaded the source code to GitHub if you want to rummage through it. There’s a couple things we need to do to get it to work from the Pi side, but I’ll cover all of that in the next post. Here’s what our data looks like:
Gravity Readings over the course of a day
Temperature. You can tell where I started cold crashing.
Performance PowerShell: Part 1
About Performance
This past November, I had the privilege of speaking with Nathan Ziehnert at MMS Jazz Edition in New Orleans, LA about PowerShell Performance. If you haven’t heard of his blog (Z-Nerd), you should definitely check it out. I’ve been meaning to write more blog posts, and I though that our topic would make a great post.
PowerShell script performance is often an afterthought, if it’s even a thought at all. Many times, we look at a script and say “It’s Works! My job here is done.” And for some instances, that’s good enough. Perhaps I’m just writing a single run script to do a one time task and then it’ll get tossed. But what about the rest of our PowerShell scripts? What about all the scripts that run our automation, task sequences, and daily tasks?
In my opinion, performance can be broken down into three categories: Cost, Maintainability, and Speed. Cost in this regard is not how much money it costs to run a script in say Azure Automation, but rather what is the resource cost on the machine that’s running it. Think CPU, memory, and disk utilization. Maintainability is the time it takes to maintain or modify the script. As our environment evolves, solutions get upgraded, or modules and snap-ins get code updates, we need to give our script the occasional tune-up. This is where format, and good coding practices come into play. Lastly, we have speed. This first blog post will focus on speed, or how fast our scripts run.
Disclaimer
What I’m covering here is general. While it may apply to 99% of use cases, be sure to test for your individual script. There are a lot of factors that can affect the speed of a script including, but not limited to, OS, PowerShell version, hardware, and run behavior. What works for one script may not work for the next. What works on one machine, may not work on the rest. What works when you tested it, will never work in production (Murphy’s Law)
What Affects Performance?
There are quite a few things that can affect performance. Some of them we can control, others we can’t. For the things we can’t control, there are often ways to mitigate or work around the constraints. I’ll take a look at some of both in this post such as:
• Test Order
• Loop Execution
• .NET Methods vs. Native Cmdlets
• Strong Typed/Typecasting
• Syntax
• Output
Testing method
For testing/measuring, I wrote a couple of functions. The first is a function named Test-Performance. It returns PSObject with all of our test data that we can use to generate visualizations. The second is a simple function that takes the mean or median results from two sets, compares them, and returns a winner along with how much faster it was. The functions:
function Test-Performance {
[CmdletBinding()]
Param(
[Parameter(Mandatory=$true,Position=1)]
[ValidateRange(5,50000)]
[int]$Count,
[Parameter(Mandatory=$true,Position=2)]
[ScriptBlock]$ScriptBlock
)
$Private:Occurrence = [System.Collections.Generic.List[Double]]::new()
$Private:Sorted = [System.Collections.Generic.List[Double]]::new()
$Private:ScriptBlockOutput = [System.Collections.Generic.List[string]]::new()
[Double]$Private:Sum = 0
[Double]$Private:Mean = 0
[Double]$Private:Median = 0
[Double]$Private:Minimum = 0
[Double]$Private:Maximum = 0
[Double]$Private:Range = 0
[Double]$Private:Variance = 0
[Double]$Private:StdDeviation = 0
$Private:ReturnObject = '' | Select-Object Occurrence,Sorted,Sum,Mean,Median,Minimum,Maximum,Range,Variance,StdDeviation,Output
#Gather Results
for ($i = 0; $i -lt $Count; $i++) {
$Timer = [System.Diagnostics.Stopwatch]::StartNew()
#$Private:Output = Invoke-Command -ScriptBlock $ScriptBlock
$Private:Output = $ScriptBlock.Invoke()
$Timer.Stop()
$Private:Result = $Timer.Elapsed
$Private:Sum += $Private:Result.TotalMilliseconds
[void]$Private:ScriptBlockOutput.Add($Private:Output)
[void]$Private:Occurrence.Add($Private:Result.TotalMilliseconds)
[void]$Private:Sorted.Add($Private:Result.TotalMilliseconds)
}
$Private:ReturnObject.Sum = $Private:Sum
$Private:ReturnObject.Occurrence = $Private:Occurrence
if (($Private:ScriptBlockOutput -notcontains "true") -and ($Private:ScriptBlockOutput -notcontains "false") -and ($Private:ScriptBlockOutput -notcontains $null)) {
$Private:ReturnObject.Output = $Private:ScriptBlockOutput
} else {
$Private:ReturnObject.Output = $null
}
#Sort
$Private:Sorted.Sort()
$Private:ReturnObject.Sorted = $Private:Sorted
#Statistical Calculations
#Mean (Average)
$Private:Mean = $Private:Sum / $Count
$Private:ReturnObject.Mean = $Private:Mean
#Median
if (($Count % 2) -eq 1) {
$Private:Median = $Private:Sorted[([Math]::Ceiling($Count / 2))]
} else {
$Private:Middle = $Count / 2
$Private:Median = (($Private:Sorted[$Private:Middle]) + ($Private:Sorted[$Private:Middle + 1])) / 2
}
$Private:ReturnObject.Median = $Private:Median
#Minimum
$Private:Minimum = $Private:Sorted[0]
$Private:ReturnObject.Minimum = $Private:Minimum
#Maximum
$Private:Maximum = $Private:Sorted[$Count - 1]
$Private:ReturnObject.Maximum = $Private:Maximum
#Range
$Private:Range = $Private:Maximum - $Private:Minimum
$Private:ReturnObject.Range = $Private:Range
#Variance
for ($i = 0; $i -lt $Count; $i++) {
$x = ($Private:Sorted[$i] - $Private:Mean)
$Private:Variance += ($x * $x)
}
$Private:Variance = $Private:Variance / $Count
$Private:ReturnObject.Variance = $Private:Variance
#Standard Deviation
$Private:StdDeviation = [Math]::Sqrt($Private:Variance)
$Private:ReturnObject.StdDeviation = $Private:StdDeviation
return $Private:ReturnObject
}
Function Get-Winner {
[CmdletBinding()]
Param(
[Parameter(Mandatory=$true,Position=1)]
[ValidateNotNullOrEmpty()]
[string]$AName,
[Parameter(Mandatory=$true,Position=2)]
[ValidateNotNullOrEmpty()]
[Double]$AValue,
[Parameter(Mandatory=$true,Position=3)]
[ValidateNotNullOrEmpty()]
[string]$BName,
[Parameter(Mandatory=$true,Position=4)]
[ValidateNotNullOrEmpty()]
[Double]$BValue
)
if ($ClearBetweenTests) {
Clear-Host
}
$blen = $AName.Length + $BName.Length + 12
$Border = ''
for ($i = 0; $i -lt $blen; $i++) {
$Border += '*'
}
if ($OutToFile) {
Out-File -FilePath $OutFileName -Append -Encoding utf8 -InputObject $Border
Out-File -FilePath $OutFileName -Append -Encoding utf8 -InputObject ([string]::Format('** {0} vs {1} **', $AName, $BName))
Out-File -FilePath $OutFileName -Append -Encoding utf8 -InputObject $Border
}
Write-Host $Border -ForegroundColor White
Write-Host ([string]::Format('** {0} vs {1} **', $AName, $BName)) -ForegroundColor White
Write-Host $Border -ForegroundColor White
if ($AValue -lt $BValue) {
$Faster = $BValue / $AValue
if ($Faster -lt 1.05) {
$Winner = 'Tie'
$AColor = [ConsoleColor]::White
$BColor = [ConsoleColor]::White
} else {
$Winner = $AName
$AColor = [ConsoleColor]::Green
$BColor = [ConsoleColor]::Red
}
} elseif ($AValue -gt $BValue) {
$Faster = $AValue / $BValue
if ($Faster -lt 1.05) {
$Winner = 'Tie'
$AColor = [ConsoleColor]::White
$BColor = [ConsoleColor]::White
} else {
$Winner = $BName
$AColor = [ConsoleColor]::Red
$BColor = [ConsoleColor]::Green
}
} else {
$Winner = 'Tie'
$AColor = [ConsoleColor]::White
$BColor = [ConsoleColor]::White
$Faster = 0
}
$APad = ''
$BPad = ''
if ($AName.Length -gt $BName.Length) {
$LenDiff = $AName.Length - $BName.Length
for ($i = 0; $i -lt $LenDiff; $i++) {
$BPad += ' '
}
} else {
$LenDiff = $BName.Length - $AName.Length
for ($i = 0; $i -lt $LenDiff; $i++) {
$APad += ' '
}
}
$AValue = [Math]::Round($AValue, 2)
$BValue = [Math]::Round($BValue, 2)
$Faster = [Math]::Round($Faster, 2)
if ($OutToFile) {
Out-File -FilePath $OutFileName -Append -Encoding utf8 -InputObject ([string]::Format('{0}: {1}{2}ms', $AName, $APad, $AValue))
Out-File -FilePath $OutFileName -Append -Encoding utf8 -InputObject ([string]::Format('{0}: {1}{2}ms', $BName, $BPad, $BValue))
Out-File -FilePath $OutFileName -Append -Encoding utf8 -InputObject ([string]::Format('WINNER: {0} {1}x Faster`r`n', $Winner, $Faster))
}
Write-Host ([string]::Format('{0}: {1}{2}ms', $AName, $APad, $AValue)) -ForegroundColor $AColor
Write-Host ([string]::Format('{0}: {1}{2}ms', $BName, $BPad, $BValue)) -ForegroundColor $BColor
Write-Host ([string]::Format('WINNER: {0} {1}x Faster', $Winner, $Faster)) -ForegroundColor Yellow
if ($PauseBetweenTests -eq $true) {
Pause
}
}
Now, you may be wondering why I went through all of that trouble when there is a perfectly good Measure-Command cmdlet available. The reason is two fold. One, I wanted the statistics to be calculated without having to call a separate function. Two, Measure-Command does not handle output, and I wanted to be able to test and capture output if needed. If you haven’t tried to use Write-Output withing a Measure-Command script block before let me show you what I’m talking about:
PS C:> Measure-Command {Write-Host "Write-Host"}
Write-Host
Days : 0
Hours : 0
Minutes : 0
Seconds : 0
Milliseconds : 12
Ticks : 128366
TotalDays : 1.48571759259259E-07
TotalHours : 3.56572222222222E-06
TotalMinutes : 0.000213943333333333
TotalSeconds : 0.0128366
TotalMilliseconds : 12.8366
PS C:> Measure-Command {Write-Output "Write-Output"}
Days : 0
Hours : 0
Minutes : 0
Seconds : 0
Milliseconds : 0
Ticks : 4005
TotalDays : 4.63541666666667E-09
TotalHours : 1.1125E-07
TotalMinutes : 6.675E-06
TotalSeconds : 0.0004005
TotalMilliseconds : 0.4005
Notice that when we call Write-Output that we don’t see the output? With my Test-Performance function, we can grab that output and still capture it. The output from the two functions looks like this:
Occurrance : {4.0353, 1.0091, 0, 0…}
Sorted : {0, 0, 0, 1.0091…}
Sum : 5.0444
Mean : 1.00888
Median : 1.0091
Minimum : 0
Maximum : 4.0353
Range : 4.0353
Variance : 2.4425469256
StdDeviation : 1.56286497356618
Output : {Write-Output, Write-Output, Write-Output, Write-Output…}
******************************
** Filter vs Where-Object **
******************************
Filter: 22ms
Where-Object: 1007.69393ms
WINNER: Filter 45.80x Faster
One other thing to mention is that I did not simply use $Start = Get-Date, $Stop = (Get-Date)-$Start. Why? Because some things happen so fast that I need to measure the speed in ticks or microseconds. Get-Date only measures time down to the millisecond, so anything less than a millisecond will be rounded to either 0 or 1 millisecond.
Test Order
With that out of the way, let’s look at test order first. Test Order is the order in which conditions are evaluated within a flow control block such as if/then or do/while. The compiler or engine will evaluate the conditions from left to right while respecting the order of operations. Why is this important? Let’s say you have the following if statement:
if (($haystack -contains "needle") -and ($x -eq 5)) {
Do-Stuff
}
We have two conditions: Does $Haystack contain the string “needle” and does $x equal 5. With the and statement we tell the engine that both must be true to meet the conditions of the if statement. The engine will evaluate the first statement, and if true, will continue through the remaining statements until it reaches either a false statement or has evaluated all statements. Let’s take a quick look at how long it takes to evaluate a few different types of conditions.
$v = 5000
$a = 1..10000
$s = 'reg.exe'
$as = (Get-ChildItem -Path C:\Windows\System32 -Filter '*.exe').Name
Test-Performance -Count 100 -ScriptBlock {$v -eq 5000}
Test-Performance -Count 100 -ScriptBlock {$a -contains 5000}
Test-Performance -Count 100 -ScriptBlock {$s -eq 'reg.exe'}
Test-Performance -Count 100 -ScriptBlock {$as -contains 'reg.exe'}
That gives me the following output:
Occurrence : {0.9741, 0, 0, 5.9834…}
Sorted : {0, 0, 0, 0…}
Sum : 40.8437
Mean : 0.408437
Median : 0
Minimum : 0
Maximum : 5.9834
Range : 5.9834
Variance : 0.538503541531
StdDeviation : 0.733828005414757
Output :
Occurrence : {0.9977, 0.9969, 0, 0.9971…}
Sorted : {0, 0, 0, 0…}
Sum : 67.7895
Mean : 0.677895
Median : 0.9934
Minimum : 0
Maximum : 3.9467
Range : 3.9467
Variance : 0.450743557675
StdDeviation : 0.671374379668304
Output :
Occurrence : {0.989, 0.9973, 0, 0…}
Sorted : {0, 0, 0, 0…}
Sum : 52.9174
Mean : 0.529174
Median : 0
Minimum : 0
Maximum : 8.9804
Range : 8.9804
Variance : 1.222762781524
StdDeviation : 1.10578604690238
Output :
Occurrence : {0.997, 0, 0, 1.0292…}
Sorted : {0, 0, 0, 0…}
Sum : 74.7425
Mean : 0.747425
Median : 0.957
Minimum : 0
Maximum : 6.9484
Range : 6.9484
Variance : 1.391867727275
StdDeviation : 1.1797744391514
Output :
What we see is that comparing if something is equal to something else is a lot faster than checking to see if an array contains an object. Now, I know, you’re thinking it’s just a couple milliseconds, but, checking if $v is equal to 5000 is almost twice as fast as checking if $as contains “reg.exe”. Keep in mind, that depending on where in the array our match is and how big our array is, that number can go up or down quite a bit. I’m just doing some simple synthetic tests to illustrate that there is a difference. When doing conditional statements like this, try to have your quicker conditions evaluated first and try to have statements that are most likely to fail evaluated first. Example:
Test-Performance -Count 100 -ScriptBlock {
if (($x -eq 100) -or ($a -contains -5090) -or ($s -eq 'test.fake') -or ($as -contains 'reg.exe')) {
$t = Get-Random
}
}
Test-Performance -Count 100 -ScriptBlock {
if (($as -contains 'reg.exe') -or ($x -eq 100) -or ($a -contains -5090) -or ($s -eq 'test.fake')) {
$t = Get-Random
}
}
Gives me the following:
Occurrence : {0.9858, 0, 0.9969, 0…}
Sorted : {0, 0, 0, 0…}
Sum : 36.8537
Mean : 0.368537
Median : 0
Minimum : 0
Maximum : 3.9959
Range : 3.9959
Variance : 0.390509577731
StdDeviation : 0.624907655362774
Output :
Occurrence : {0.9974, 0, 0.9971, 0…}
Sorted : {0, 0, 0, 0…}
Sum : 54.8193
Mean : 0.548193
Median : 0.4869
Minimum : 0
Maximum : 3.9911
Range : 3.9911
Variance : 0.425326705251
StdDeviation : 0.652170763873236
Output :
We can see that by changing the order of the evaluated conditions, our code runs in about 2/3 the time. Again, these are generic tests to illustrate the effect that test order has on execution time, but they illustrate some basic guidelines that should be able to be applied to most situations. Be sure to test your code.
Loop Execution
Now that I’ve gotten test order out of the way, let’s start with loop execution. Sometimes when we are working with a loop, like say stepping through an array, we don’t need to do something for every element. Sometimes, we are looking for a specific element and don’t care about anything after that. In these cases, break is our friend. For our first example, I’ll create an array of all years in the 1900’s. I’ll then loop through each one and write some output when I find 1950.
$Decade = 1900..1999
$TargetYear = 1950
$NoBreakResult = Test-Performance -Count 10 -ScriptBlock {
for ($i = 0; $i -lt $Decade.Count; $i++) {
if ($Decade[$i] -eq 1950) {
Write-Output "Found 1950"
}
}
}
$BreakResult = Test-Performance -Count 10 -ScriptBlock {
for ($i = 0; $i -lt $Decade.Count; $i++) {
if ($Decade[$i] -eq 1950) {
Write-Output "Found 1950"
break
}
}
}
Get-Winner "No Break" $NoBreakResult.Median "Break" $BreakResult.Median
Our output looks as follows:
*************************
** No Break vs Break **
*************************
No Break: 0.38ms
Break: 0.28ms
WINNER: Break 1.35x Faster
$NoBreakResult
Occurrence : {0.8392, 0.4704, 0.4566, 0.444…}
Sorted : {0.3425, 0.3438, 0.3442, 0.3445…}
Sum : 47.8028
Mean : 0.478028
Median : 0.38175
Minimum : 0.3425
Maximum : 2.6032
Range : 2.2607
Variance : 0.127489637016
StdDeviation : 0.357056910052165
Output : {Found 1950, Found 1950, Found 1950, Found 1950…}
$BreakResult
Occurrence : {3.2739, 0.3445, 0.32, 0.3167…}
Sorted : {0.2657, 0.266, 0.266, 0.2662…}
Sum : 40.0342
Mean : 0.400342
Median : 0.2871
Minimum : 0.2657
Maximum : 3.2739
Range : 3.0082
Variance : 0.182262889036
StdDeviation : 0.426922579674582
Output : {Found 1950, Found 1950, Found 1950, Found 1950…}
As expected, the instance with the break commandwas about 25% faster. Next I’ll take a look at a different method that I don’t see in too many peoples code, the While/Do-While loop.
$DoWhileResult = Test-Performance -Count 100 -ScriptBlock {
$i = 0
$Year = 0
do {
$Year = $Decade[$i]
if ($Year -eq 1950) {
Write-Output "Found 1950"
}
$i++
} While ($Year -ne 1950)
}
Which nets me the following:
****************************
** Do-While vs No Break **
****************************
Do-While: 0.24ms
No Break: 0.38ms
WINNER: Do-While 1.57x Faster
$DoWhileResult
Occurrence : {0.9196, 0.313, 0.2975, 0.2933…}
Sorted : {0.2239, 0.224, 0.2242, 0.2243…}
Sum : 33.8217
Mean : 0.338217
Median : 0.2436
Minimum : 0.2239
Maximum : 5.0187
Range : 4.7948
Variance : 0.262452974211
StdDeviation : 0.512301643771519
Output : {Found 1950, Found 1950, Found 1950, Found 1950…}
As we can see, Do-While is also faster than running through the entire array. My example above does not have any safety mechanism for running beyond the end of the array or not finding the element I’m searching for. In practice, be sure to include such a condition/catch in your loop. Next, I’m going to compare the performance between a few different types of loops. Each loop will run through an array of numbers from 1 to 10,000 and calculate the square root of each. I’ll use the basic for loop as the baseline to compare against the other methods.
$ForLoop = Test-Performance -Count 100 -ScriptBlock {
$ForArray = 1..10000
for ($i = 0; $i -lt 10000; $i++) {
$sqrt = [Math]::Sqrt($Array[$i])
}
}
$ForEachLoop = Test-Performance -Count 100 -ScriptBlock {
$ForEachArray = 1..10000
foreach ($item in $ForEachArray) {
$sqrt = [Math]::Sqrt($item)
}
}
$DotForEachLoop = Test-Performance -Count 100 -ScriptBlock {
$DotForEachArray = 1..10000
$DotForEachArray.ForEach{
$sqrt = [Math]::Sqrt($_)
}
}
$ForEachObjectLoop = Test-Performance -Count 100 -ScriptBlock {
$ForEachObjectArray = 1..10000
$ForEachObjectArray | ForEach-Object {
$sqrt = [Math]::Sqrt($_)
}
}
So how do they fare?
***********************
** For vs For-Each **
***********************
For: 3ms
For-Each: 1.99355ms
WINNER: For-Each 1.50x Faster
***********************
** For vs .ForEach **
***********************
For: 3ms
.ForEach: 1150.95495ms
WINNER: For 383.65x Faster
*****************************
** For vs ForEach-Object **
*****************************
For: 3ms
ForEach-Object: 1210.7644ms
WINNER: For 403.59x Faster
Quite a bit of difference. Let’s take a look at the statistics for each of them.
$ForLoop
Occurrence : {38.8952, 3.9984, 2.9752, 2.966…}
Sorted : {0, 0, 1.069, 1.9598…}
Sum : 330.7618
Mean : 3.307618
Median : 2.9731
Minimum : 0
Maximum : 38.8952
Range : 38.8952
Variance : 26.100085284676
StdDeviation : 5.10882425658546
Output :
$ForEachLoop
Occurrence : {7.0133, 1.9972, 1.9897, 0.9678…}
Sorted : {0.9637, 0.9678, 0.9927, 0.9941…}
Sum : 187.5277
Mean : 1.875277
Median : 1.99355
Minimum : 0.9637
Maximum : 7.0133
Range : 6.0496
Variance : 0.665303603371
StdDeviation : 0.815661451443551
Output :
$DotForEachLoop
Occurrence : {1225.7258, 1169.9073, 1147.9007, 1146.9384…}
Sorted : {1110.0618, 1110.0688, 1113.9906, 1114.0656…}
Sum : 114948.9291
Mean : 1149.489291
Median : 1150.95495
Minimum : 1110.0618
Maximum : 1225.7258
Range : 115.664
Variance : 534.931646184819
StdDeviation : 23.1285893686757
Output :
$ForEachObjectLoop
Occurrence : {1217.7802, 1241.7037, 1220.686, 1249.688…}
Sorted : {1181.8081, 1188.8231, 1188.8291, 1191.7818…}
Sum : 121345.8078
Mean : 1213.458078
Median : 1210.7644
Minimum : 1181.8081
Maximum : 1274.6289
Range : 92.8208000000002
Variance : 318.356594303116
StdDeviation : 17.8425501065043
Output :
If you notice on the for and for-each loops, the first run is significantly higher than the other entries (in fact, it’s the slowest run in the batch for each) whereas the method and cmdlet versions are much more consistent. This is due to the behavior of those methods. With a for and for-each loop, the method loads the entire collection into memory before processing. This causes the first run of the loop to take a bit longer, although, it’s still faster than the method or cmdlet. The cmdlet and method are slower as they load one iteration into memory at a time which is slower than loading the sum all at once (think random read/write vs sequential). The for loop is slightly slower than for-each because it has to evaluate the condition before proceeding through the next iteration.
.NET Methods vs. Cmdlets
Next, I’ll take a look at some of the differences between some of the common “native” PowerShell cmdlets and their .NET counterparts. I’m going to start with what will likely be the most common things that you’ll encounter in your scripts or scripts that you use, the array. We’ve probably all used them, and maybe even continue to use them. But should you? First, Let’s look at adding items to an array. We frequently start with blank arrays and add items to them as we go along.
$ArrayResult = Test-Performance -Count 100 -ScriptBlock {
$Array = @()
for ($i =0; $i -lt 10000; $i ++) {
$Array += $i
}
}
$ListResult = Test-Performance -Count 100 -ScriptBlock {
$List = [System.Collections.Generic.List[PSObject]]::new()
for ($i =0; $i -lt 10000; $i ++) {
[void]$List.Add($i)
}
}
Get-Winner "Array" $ArrayResult.Median "List" $ListResult.Median
*********************
** Array vs List **
*********************
Array: 2274ms
List: 2.97945ms
WINNER: List 763.23x Faster
$ArrayResult
Occurrence : {2407.5676, 2311.8239, 2420.5336, 2268.9383…}
Sorted : {2190.1917, 2200.1205, 2219.1807, 2223.0887…}
Sum : 228595.7729
Mean : 2285.957729
Median : 2274.42135
Minimum : 2190.1917
Maximum : 2482.3996
Range : 292.2079
Variance : 2527.01010551066
StdDeviation : 50.2693754239165
Output :
$ListResult
Occurrence : {24.9343, 19.9729, 3.9623, 5.9836…}
Sorted : {0.9974, 1.9776, 1.9925, 1.994…}
Sum : 373.999
Mean : 3.73999
Median : 2.97945
Minimum : 0.9974
Maximum : 51.8617
Range : 50.8643
Variance : 37.0781465771
StdDeviation : 6.0891827511662
Output :
Modifying an existing array can be a VERY expensive operation. Arrays are fixed length and can not be expanded or contracted. When we add or subtract an element, the engine first has to create a new array of size n + 1 or n – 1 and then copy each of the elements from the old array into the new one. This is slow, and can consume a lot of memory while the new array is being created and contents copied over. Lists on the other hand are not statically sized. The advantage of an array however is that they have a smaller memory footprint. Since an array is stored as a whole consecutively in memory, it’s size can roughly be calculated as SizeOf(TypeOf(Element))*NumElements. A Linked list on the other hand is not stored consecutively within memory and is a bit larger since each element contains a pointer to the next object. It’s size can roughly be calculated as (SizeOf(TypeOf(Element)) + SizeOf(Int)) * NumElements. You might be thinking, well, if an array is stored in a consecutive memory blocks, once the array is established, it should be faster to work with right? I’ll test.
[int[]]$Array = 1..10000
$List = [System.Collections.Generic.List[int]]::new()
for ($i = 1; $i -lt 10001; $i++) {
[void]$List.Add($i)
}
$ArrayForEachResult = Test-Performance -Count 100 -ScriptBlock {
foreach ($int in $Array) {
$int = 5
}
}
$ListForEachResult = Test-Performance -Count 100 -ScriptBlock {
foreach ($int in $List) {
$int = 5
}
}
First, we create an array of 10,000 elements with the numbers 1 through 10,000 inclusive. We declare the array as an integer array to ensure we are comparing to objects of the same type so to speak. We then create a list<int> and fill with the same values. So how do they fare?
***************************************
** Array For-Each vs List For-Each **
***************************************
Array For-Each: 1.47ms
List For-Each: 0.83ms
WINNER: List For-Each 1.77x Faster
$ArrayForEachResult
Occurrence : {4.643, 1.4673, 1.4029, 1.3336…}
Sorted : {1.3194, 1.3197, 1.3255, 1.3272…}
Sum : 156.4036
Mean : 1.564036
Median : 1.47125
Minimum : 1.3194
Maximum : 4.643
Range : 3.3236
Variance : 0.136858367504
StdDeviation : 0.369943735592319
Output : {, , , …}
$ListForEachResult
Occurrence : {7.233, 1.723, 0.8305, 0.8632…}
Sorted : {0.6174, 0.6199, 0.6203, 0.6214…}
Sum : 164.8467
Mean : 1.648467
Median : 0.83335
Minimum : 0.6174
Maximum : 71.705
Range : 71.0876
Variance : 50.017547074011
StdDeviation : 7.07230846852787
Output : {, , , …}
As we can see, the list still out-performs the array, although by less of a margin than it did during the manipulation test. I suspect that this is due to the cmdlet having to load the entirety of the array as opposed to just pointers with the list. Now let’s compare .NET Regex vs the PowerShell method. For this, I’m going to be replacing text instead of just checking for the match. Let’s look at the code.
$Haystack = "The Quick Brown Fox Jumped Over the Lazy Dog 5 Times"
$Needle = "\ ([\d]{1})\ "
$NetRegexResult = Test-Performance -Count 1000 -ScriptBlock {
[regex]::Replace($Haystack, $Needle, " $(Get-Random -Minimum 2 -Maximum 9) ")
Write-Output $Haystack
}
$PoshRegexResult = Test-Performance -Count 1000 -ScriptBlock {
$Haystack -replace $Needle, " $(Get-Random -Minimum 2 -Maximum 9) "
Write-Output $Haystack
}
Get-Winner ".NET RegEx" $NetRegexResult.Median "PoSh RegEx" $PoshRegexResult.Median
Nothing too fancy here. We take our haystack (the sentence), look for the needle (the number of times the fox jumped over the dog) and replace it with a new single digit random number.
********************************
** .NET RegEx vs PoSh RegEx **
********************************
.NET RegEx: 0.23ms
PoSh RegEx: 0.23ms
WINNER: Tie 1x Faster
$NetRegexResult
Occurrence : {0.7531, 0.2886, 0.3572, 0.3181…}
Sorted : {0.2096, 0.2106, 0.211, 0.2189…}
Sum : 282.3331
Mean : 0.2823331
Median : 0.23035
Minimum : 0.2096
Maximum : 2.2704
Range : 2.0608
Variance : 0.03407226235439
StdDeviation : 0.184586733961003
Output : {The Quick Brown Fox Jumped Over the Lazy Dog 5 Times The Quick Brown Fox Jumped Over the Lazy Dog 5 Times, The Quick Brown Fox Jumped Over the Lazy Dog 8 Times
The Quick Brown Fox Jumped Over the Lazy Dog 5 Times, The Quick Brown Fox Jumped Over the Lazy Dog 4 Times The Quick Brown Fox Jumped Over the Lazy Dog 5 Times,
The Quick Brown Fox Jumped Over the Lazy Dog 4 Times The Quick Brown Fox Jumped Over the Lazy Dog 5 Times…}
$PoshRegexResult
Occurrence : {0.7259, 0.2546, 0.2513, 0.2486…}
Sorted : {0.2208, 0.2209, 0.2209, 0.2211…}
Sum : 279.0913
Mean : 0.2790913
Median : 0.231
Minimum : 0.2208
Maximum : 2.1124
Range : 1.8916
Variance : 0.03001781767431
StdDeviation : 0.173256508317321
Output : {The Quick Brown Fox Jumped Over the Lazy Dog 8 Times The Quick Brown Fox Jumped Over the Lazy Dog 5 Times, The Quick Brown Fox Jumped Over the Lazy Dog 6 Times
The Quick Brown Fox Jumped Over the Lazy Dog 5 Times, The Quick Brown Fox Jumped Over the Lazy Dog 7 Times The Quick Brown Fox Jumped Over the Lazy Dog 5 Times,
The Quick Brown Fox Jumped Over the Lazy Dog 2 Times The Quick Brown Fox Jumped Over the Lazy Dog 5 Times…}
Surprisingly, or not surprisingly, the two methods are pretty much dead even. This is one of the cases where I suspect the PowerShell cmdlet is pretty much just a wrapper/alias for the corresponding .NET equivalent. You might ask yourself why you would use the .NET methods if the PowerShell cmdlets net the same performance. The answer (and this applies in a lot of cases) is that the PowerShell Cmdlets don’t always offer the same options as their .NET counterparts. I’m going to use String.Split as an example. Take a look at the two documentation pages for “String” -Split and String.Split. You may have noticed that they aren’t entirely the same. Far from it actually. In most cases, they will return you with the same results, but they don’t both support the same options. For example, if you want to remove blank entries, you’ll need to use the .Split() method. But what about performance?
$SplitString = "one,two,three,four,five,six,seven,eight,nine,ten,"
$DashSplitResult = Test-Performance -Count 10000 -ScriptBlock {
$SplitArray = $SplitString -Split ','
}
$DotSplitResult = Test-Performance -Count 10000 -ScriptBlock {
$SplitArray = $SplitString.Split(',')
}
Get-Winner "-Split" $DashSplitResult.Median ".Split()" $DotSplitResult.Median
**************************
** -Split vs .Split() **
**************************
-Split: 0.13ms
.Split(): 0.12ms
WINNER: .Split() 1.1x Faster
$DashSplitResult
Occurrence : {0.4855, 0.1837, 0.2387, 0.1916…}
Sorted : {0.1128, 0.113, 0.1131, 0.1131…}
Sum : 1613.99049999999
Mean : 0.161399049999999
Median : 0.125
Minimum : 0.1128
Maximum : 2.1112
Range : 1.9984
Variance : 0.0234987082460975
StdDeviation : 0.153292883872988
Output : {, , , …}
$DotSplitResult
Occurrence : {0.552, 0.1339, 0.1245, 0.1227…}
Sorted : {0.1052, 0.1056, 0.1056, 0.1057…}
Sum : 1485.38330000001
Mean : 0.148538330000001
Median : 0.1162
Minimum : 0.1052
Maximum : 1.9226
Range : 1.8174
Variance : 0.0186857188798111
StdDeviation : 0.136695716391594
Output : {, , , …}
Pretty close, but .Split does edge out -Split by just a hair. Is it worth re-writing all of your code? Doubtful. But if you use string splitting methods frequently, it may be worth doing some testing with your common use cases to see if there could be an impact. And with that, I’m going to wrap up the first part of this post.
Sending TiltPi Data to Azure Log Analytics via PHP
I use a couple Tilt Hydrometers to track and log the fermentation data for my beers. While there are a few different ways that one can upload the data to the internet, I noticed that there wasn’t an automated way to upload to Azure Log Analytics. TiltPi is built on a customized variant of Raspbian. The current version utlizes Raspbian Stretch, which in turn is based on Debian Stretch. Microsoft supports Linux and has an OMS agent available for both x86 and x64 variants of Linux. They don’t, however, currently support the ARM platform which the Raspberry Pi boards are built on. Attempting to install the OMS Agent via the script from GitHub fails. While the agent is built on Ruby and Fluentd which are both compatable with ARM64, other components such as omi are not. If all you need is syslogs, there is a fluentd plugin for OMS which Microsoft supports. Unfortunately, the Tilt app does not write to the syslog. It writes to it’s own CSV formatted log. That leaves us with two options: write a daemon to forward new entries to syslog or utilize the cloudurl and write the data directly to Log Analytics using the REST API. The first sounded like more effort than I wanted to put into this project and would likely be purpose built for this and this alone. The second method though, sounded a bit easier, and more flexible. Thankfully, Microsoft has a nice bit of documentation regarding the HTTP Data Collector API on their docs website.
I was able to use this information to build a framework for writing data directly to Azure via a PHP script. Microsoft’s documentation thankfully has all the information we need. The examples helped with some of the basic pieces that I needed to get going, however, I did have to do a bit of playing around to get the signature to work since translating from one language to another is not always straight forward. .NET for example requires byte arrays when calling encode/decode/hash functions whereas PHP just wants the raw string. When calling the API, part of the HTTP header is a Signature that authorizes you and tells Log Analytics where to put the data. The basic formula is base64_encode(sha256_hmac(base64_decode(<SharedKey>), <HashData>)). Let’s break that down. First, we need to create our HashData. This is a string formatted as follows: <SendMethod>\n<PayloadLength>\n<ContentType>\nx-ms-date:<RFC1123Date>\n<SendResource>. All of these are detailed in the documentation, but essentially we have “POST\n<PayloadLength>\napplication/json\nx-ms-date: <RFC1123Date>\n/api/logs” where <PayloadLength> is the length of our data we are going to send and <RFC1123Date> is the current date/time in RFC 1123 format. Once we have that string, we need to ensure that it is encoded as utf8. Once we have the utf8 encoded version of the string, we pass that to hash_hmac and have it create a sha256 hash using that and our base64 decoded key. We then do a base64_encode on the resulting hash and create our signature; “SharedKey <WorkspaceID>:<EncodedHash>”. After we have that, we can use the curl libraries to send the data to OMS. The code for our function looks like this:
public function Send_Log_Analytics_Data($Payload) {
#Get current timestamp (UTC) and Payload length
$Rfc1123Date = gmdate('D, d M Y H:i:s T');
$PayloadLength = strlen($Payload);
#Generate the Signature
$StringToSign = "{$this->SendMethod}\n{$PayloadLength}\n{$this->SendContentType}\nx-ms-date:{$Rfc1123Date}\n{$this->SendResource}";
$Utf8String = utf8_encode($StringToSign);
$Hash = hash_hmac('sha256', $Utf8String, base64_decode($this->PrimaryKey), true);
$EncodedHash = base64_encode($Hash);
$Signature = "SharedKey {$this->WorkspaceId}:{$EncodedHash}";
#Build the URI and headers for cURL
$Uri = "https://{$this->WorkspaceId}.ods.opinsights.azure.com{$this->SendResource}?api-version={$this->SendApiVersion}";
$Handle = curl_init($Uri);
$Headers = array("Authorization: {$Signature}", "Log-Type: {$this->LogType}", "x-ms-date: {$Rfc1123Date}", "time-generated-field: {$this->TimeStampField}", "Content-Type: {$this->SendContentType}");
#Set cURL Options
curl_setopt($Handle, CURLOPT_POST, true);
curl_setopt($Handle, CURLOPT_HEADER, true) or die("Failed to set cURL Header");
curl_setopt($Handle, CURLOPT_HTTPHEADER, $Headers) or die("Failed to set cURL Header");
curl_setopt($Handle, CURLOPT_POSTFIELDS, $Payload);
curl_setopt($Handle, CURLOPT_RETURNTRANSFER, true) or die("Failed to set cURL Return Transfer");
#Execute cURL and return the result
$Result = curl_exec($Handle);
return curl_getinfo($Handle, CURLINFO_HTTP_CODE);
}
Now that we can send data, what data are we sending? The Tilt app sends the following pieces of information to whatever cloud url you specify in the logging tab:
• Timepoint (Excel datetime value)
• Temp (deg F)
• SG (Specific Gravity)
• Beer (Name of the Beer)
• Color (Color of the Tilt)
• Comment (blank unless you manually send data and add a comment)
We can take this post data and create our payload by converting it into a JSON formatted string.
$TimeStamp = gmdate('Y-m-d\TH:i:s.v\Z');
$Entry = "[{\"Timepoint\": \"{$TimeStamp}\", \"Temp\": {$Temp}, \"SG\": {$SG}, \"Beer\": \"{$Beer}\", \"Color\": \"{$Color}\", \"Comment\": \"{$Comment}\",\"Source\": \"TiltPHP\"}]";
Since we’re doing this in real time as data is sent, we are ignoring the timestamp that the Tilt app has created and instead using our own. This lets us skip having to convert the Excel formatted date into one that Log Analytics can use. If you need to use the Excel date, it’s just the number of days that have passed since 12:00AM 1900-01-01. The entry we created above is what we pass to the Send_Log_Analytics_Data as the $Payload parameter. And now, we can sit down, have a beer, and watch data flow into Log Analytics. If you’re interested in looking at the full code, I’ve posted it up on my GitHub space. Soon I’ll write something up on how to do something with that data 😉
|
__label__pos
| 0.854827 |
Odoo Help
1
Where is the code that redirects to the home page (page after successful login) of a user after login.
By
Gopakumar N G
on 10/31/13, 2:57 AM 3,501 views
Where is the code that redirects to a page (page after successful login) of a user after login in OpenERP 7.
1
tolstoj
--tolstoj--
949
| 6 5 8
Germany
--tolstoj--
hi
tolstoj
On 11/18/13, 6:54 AM
you can use window.location = "url" or instance.web.redirect() in chrome.js:754
instance.web.redirect = function(url, wait) { if (instance.client && instance.client.crashmanager) { instance.client.crashmanager.active = false; }
var wait_server = function() {
instance.session.rpc("/web/webclient/version_info", {}).done(function() {
window.location = url;
}).fail(function() {
setTimeout(wait_server, 250);
});
};
if (wait) {
setTimeout(wait_server, 1000);
} else {
window.location = url;
}
};
I have created a form (like "Login" in base.xml) and I want to redirect to that page after Login, which asks for a One Time Password sent to mobile. How can I redirect to this page after login ?
Gopakumar N G
on 11/20/13, 4:54 AM
Gopakumar, did you find your solution to redirect to your page?
BISSTECH SRL
on 1/19/17, 10:15 AM
About This Community
This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.
Register
Odoo Training Center
Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.
Test it now
Question tools
1 follower(s)
Stats
Asked: 10/31/13, 2:57 AM
Seen: 3501 times
Last updated: 3/16/15, 8:10 AM
|
__label__pos
| 0.590438 |
Fat Client
Definition - What does Fat Client mean?
A fat client is a networked computer with many locally-stored programs or resources and little dependence on network resources, such as auxiliary drives, CD-RW/DVD players or software applications. Typically, users prefer fat client computers over thin clients because fat clients allow easy customization and greater control over installed programs and system configuration.
Because output is locally generated, a fat client also enables a more sophisticated graphical user interface (GUI) and reduced server load.
A fat client is also known as a thick client.
Techopedia explains Fat Client
A fat client is often built with expensive hardware with many moving parts and should not be placed in a hostile environment. Otherwise, the fat client may not function optimally.
An example of a fat client is a computer that handles the majority of a complex drawing’s editing with sophisticated, locally stored software. The system designer determines editing or viewing access to this software.
A fat client has several advantages, including the following:
• Fewer server requirements because it does most of the application processing
• More offline work because a server connection is often not required
• Multimedia-rich application processing, such as video gaming facilitation, because there are no increased server bandwidth requirements
• Runs more applications because many fat clients require that an operating system reside on a local computer
• Easy network connection at no extra cost because many users have fast local PCs
• Higher server capacity because each fat client handles more processing, allowing the server to serve more clients
Share this:
|
__label__pos
| 0.968517 |
DEV Community
Cover image for React.useEffect()
Abhishek
Abhishek
Posted on
React.useEffect()
Understanding Side Effects
React is centered around functional programming. A side effect is any execution that affects something outside the scope of the function being executed. It is not a React specific term, it’s a general concept about the behavior of a function. For example, if a function modifies a global variable, then that function is introducing a side effect — the global variable doesn’t belong to the scope of the current function.
Some examples of side effects in React components are:
• Making asynchronous API calls for data
• Manually updating the DOM element
• Updating global variables from inside a function
Hooks are available for functional components.useEffect hook is an extremely powerful an versatile tool, allowing you to even create your own, custom hooks.
Basic use & behavior
useEffect is - as the name suggests - a hook to perform arbitrary side effects during a life of a component.
It is basically a hook replacement for the "old-school" lifecycle methods componentDidMount, componentDidUpdate and componentWillUnmount.
It allows you to execute lifecycle tasks without a need for a class component. So you can now make side effects inside a functional component. This
import React, { useEffect } from "react";
function SimpleUseEffect() {
useEffect(() => {
alert("Component Rendered")
});
return (
<div>
<b>A Simple use of useEffect...</b>
</div>
)
}
Enter fullscreen mode Exit fullscreen mode
In the code above, we used the useEffect hook. It takes a function as input, which is executed after the initial rendering, as well as re-rendering, of the component. After each rendering, one the DOM has been updated and the function passed to useEffect is invoked. In the above scenario, the component gives an alert after the initial rendering of the component.
There are two arguments that are passed to useEffect():
1. Effect: An anonymous callback function that houses your useEffect logic. This logic is executed based upon how you set up useEffect() to run
2. Dependency array: The second is an array that takes in comma-delimited variables called the dependency list. This is how you change the way useEffect() operates.
we van achieve different life cycle like: componentDidMount, componenntDidUpdate & componentwillUnmount using effect & dependecy array.
Here are the more common ways useEffect() hooks are implemented:
• componentDidMount:For a useEffect() invocation to only run on every mount and unmount, use the useEffect() hook in the following manner:
useEffect(() => {
// some component logic to execute...
}, []);
/*
Notice the empty array as the second argument above.
We don't pass anything to the array as we don't want useEffect() to depend on anything - thus the purpose of having the dependency list in the first place.
*/
Enter fullscreen mode Exit fullscreen mode
• componentDidUpdate:For a useEffect() invocation to run less, or more, often based upon what that useEffect() invocation is dependent on (i.e. — what is passed through to the dependency list), use the useEffect() hook in the following manner:
const [value, setValue] = useState(0);
useEffect(() => {
// some component logic to execute...
}, [value, setValue]);
/*
Notice the dependency array as the second argument above.
We pass 'value' to the array as an example to showcase how this hook can work. This useEffect() invocation will execute every single time 'value' is updated.
Another thing to mention is that arguments in the dependency list don't have to come from other hooks like they do in this example - they can be other forms of data that are assigned to a particular variable where the underlying assigned values can be/are mutated.
*/
Enter fullscreen mode Exit fullscreen mode
• componentWillUnmount:
React.useEffect(
() => {
val.current = props;
},
[props]
);
React.useEffect(() => {
return () => {
console.log(props, val.current);
};
Enter fullscreen mode Exit fullscreen mode
Top comments (0)
|
__label__pos
| 0.794273 |
1
I already experienced this same problem with Craft Commerce a while ago (Error on functions in queue: "Session does not exist in a console request.") and got a solution that solved the problem for the function described in that question, but this time the problem occurs on a different function and I can't seem to find a solution.
There's a connection with the Lightspeed API to update product stock values every 15 minutes and to import new products. These are all handled by the queue and work most of the time, but sometimes it throws an error saying "Session does not exist in a console request" Queue manager screenshot
Here are all functions that are performed in this action (I know it's a lot, but I am getting quite desperate):
Controller action
public function actionImportNewProducts()
{
Stock::$plugin->lightspeedService->refreshToken();
$allowedCategories = Craft::$app->request->getBodyParam('categories');
$startParam = Craft::$app->request->getBodyParam('startDate');
$startDate = new \DateTime($startParam['date']);
$endParam = Craft::$app->request->getBodyParam('endDate');
if (!$endParam) {
$endDate = new \DateTime();
} else {
$endDate = new \DateTime($endParam['date']);
}
$endDate = $endDate->modify('tomorrow midnight');
$limit = 100;
$pages = Stock::$plugin->lightspeedService->getPagination();
$productCount = 0;
for ($page = 0; $page < $pages; $page++) {
$offset = $page * $limit;
$inventory = json_decode(Stock::$plugin->lightspeedService->getInventory($offset, '["ItemShops", "Category", "TaxClass"]'), true);
$items = $inventory['Item'];
foreach ($items as $item) {
$createdAt = new \DateTime($item['createTime']);
$createdAt = $createdAt->modify('midnight');
if ($createdAt >= $startDate && $createdAt <= $endDate) {
$category = $item['Category'];
if (in_array($category['categoryID'], $allowedCategories)) {
if (!$item['archived'] or $item['archived'] == 'false') {
Stock::$plugin->productService->queueImportProduct($item);
$productCount++;
}
}
}
}
}
Craft::$app->session->setNotice($productCount . ' producten aan het importeren.');
}
LightspeedService refreshToken
public function refreshToken()
{
$refreshToken = Stock::getInstance()->settings->refreshToken;
if (!$refreshToken) {
Craft::$app->session->setError('Lightspeed refreshtoken ontbreekt');
return false;
}
$client = new GuzzleClient();
$url = 'https://cloud.lightspeedapp.com/oauth/access_token.php';
$body['multipart'] = [
[
'name' => 'client_id',
'contents' => getenv('LIGHTSPEED_CLIENT_ID')
],
[
'name' => 'client_secret',
'contents' => getenv('LIGHTSPEED_CLIENT_SECRET')
],
[
'name' => 'refresh_token',
'contents' => $refreshToken
],
[
'name' => 'grant_type',
'contents' => 'refresh_token'
]
];
try {
$request = $client->request('POST', $url, $body);
$response = $request->getBody()->getContents();
$response = json_decode($response);
$accessToken = $response->access_token;
if (!$accessToken) {
return $this->asJson($response);
}
$settings['accessToken'] = $accessToken;
$plugin = Craft::$app->getPlugins()->getPlugin('stock');
Craft::$app->getPlugins()->savePluginSettings($plugin, $settings);
return $response;
} catch (ClientException $e) {
return $e->getMessage();
}
}
LightspeedService getPagination
public function getPagination()
{
$inventory = json_decode(Stock::$plugin->lightspeedService->getInventory(), true);
$attributes = $inventory['@attributes'];
$count = intval($attributes['count']);
$limit = intval($attributes['limit']);
return ceil($count / $limit);
}
LightspeedService getInventory
public function getInventory($offset = 0, $relations = null)
{
Stock::$plugin->lightspeedService->refreshToken();
$client = new GuzzleClient();
$url = getenv('LIGHTSPEED_API_URL') . '/API/Account/' . getenv('LIGHTSPEED_ACCOUNT_ID') . '/Item.json?offset=' . $offset;
if ($relations) {
$url = $url . "&load_relations={$relations}";
}
$headers = [
'Authorization' => 'Bearer ' . Stock::getInstance()->settings->accessToken
];
try {
$request = $client->request('GET', $url, [
'headers' => $headers
]);
$response = $request->getBody()->getContents();
return $response;
} catch (ClientException $e) {
return $e->getMessage();
}
}
ProductService queueImportProduct
public function queueImportProduct($item)
{
Craft::$app->queue->push(new ImportProduct([
'item' => $item
]));
}
Job importProduct
public function execute($queue)
{
Stock::$plugin->productService->importProduct($this->item);
}
ProductService importProduct
I had read in another question that it could help to replace all product updates by DB queries, but that didn't solve my problem.
public function importProduct($item)
{
$sku = $item['systemSku'];
$price = Stock::$plugin->lightspeedService->getDefaultPrice($item);
$stock = Stock::$plugin->lightspeedService->getItemQoh($item);
$productTypeId = Stock::$plugin->productService->getProductType($item['Category']);
$taxCategoryId = Stock::$plugin->lightspeedService->getTaxCategoryId($item['TaxClass']['taxClassID']);
$variant = Variant::find()->sku($sku)->one();
if (!$variant) {
$product = new Product();
$product->typeId = $productTypeId;
$product->enabled = false;
$product->title = $item['description'];
$product->promotable = true;
$product->taxCategoryId = $taxCategoryId;
$variant = new Variant();
$variant->isDefault = true;
$variant->sku = $sku;
$variant->price = (float) $price;
$variant->stock = $stock;
$product->setVariants([$variant]);
Craft::$app->elements->saveElement($product);
} else {
$product = $variant->product;
Craft::$app->getDb()->createCommand()->update('{{%commerce_products}}',
[
'taxCategoryId' => $taxCategoryId,
],
[
'id' => $variant->product->id
]
)->execute();
Craft::$app->getDb()->createCommand()->update('{{%commerce_variants}}',
[
'sku' => $sku,
'price' => (float) $price,
'stock' => $stock
],
[
'id' => $variant->id
]
)->execute();
}
$lightspeedProductRecord = LightspeedProductsRecord::findOne(['itemId' => $item['itemID']]);
if (!$lightspeedProductRecord) {
$lightspeedProductRecord = new LightspeedProductsRecord();
$lightspeedProductRecord->itemId = $item['itemID'];
}
$lightspeedProductRecord->variantId = $variant->id;
$lightspeedProductRecord->save();
}
Any help will be appreciated!
1 Answer 1
2
Ok so with these the trick is to look for anything that might involve a request session, which is not available when you're running things via a console request.
In this case there's at least one obvious suspect line:
Craft::$app->session->setError('Lightspeed....);
Indeed there's more than one of these.
It's basically the same problem as previously - i.e. if there's no session, then you can't set errors on the session (or retrieve a cart from the session).
So you might need to check if the current request is a console request (if this code is ever run in a non console way) ... And deal with errors differently if so.
if (Craft::$app->getRequest()->getIsConsoleRequest()) {
...send errors to a log file, email an alert, ....
}
(As to why this is running as a console request - it depends how it is called. E.g. you're explicitly running it from the console, or your queue runner is doing so....)
Your Answer
By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.
Not the answer you're looking for? Browse other questions tagged or ask your own question.
|
__label__pos
| 0.983594 |
How To Use Runway Gen-3 Alpha - (Runway Gen-3 Tutorial) - Gen 3 Alpha Guide
The video tutorial for Runway Gen-3 Alpha provides a comprehensive guide on generating videos with precision. It covers topics such as managing credits, refining prompts for quality outputs, exploring advanced features, and directing prompts effectively to enhance video projects.
In the video tutorial for Runway Gen-3 Alpha, viewers are guided through the process of generating videos with remarkable accuracy. The tutorial begins by explaining the credit system, where Gen-3 Alpha uses 10 credits per second of video generated. It is important to be mindful of the number of credits available, especially for those on the $12 a month plan, which starts with 625 credits. Viewers are advised to start with a 5-second duration to refine prompts without depleting credits too quickly.
The importance of providing detailed descriptions for prompts is emphasized, as this directly impacts the quality of the generated content. The tutorial demonstrates how different descriptions can lead to varying outputs, with an example comparing a basic prompt like “Fruit sitting on a table in the jungle” to a detailed one. It is shown how the level of detail in the description influences the coherence and quality of the generated footage.
Various features of Runway Gen-3 Alpha are explored, such as reusing settings, viewing and copying prompts, and custom presets for saving preferred prompts. The tutorial also covers options like removing watermarks, downloading videos, and using different camera styles, lighting techniques, movement speeds, movement types, and aesthetics to enhance video projects. Tips on directing prompts effectively for desired results are shared.
The video delves into specific words and phrases that can be used to direct the generated content, including different camera angles like low angle, high angle, and overhead shots, as well as movement types like grows, emerges, and unfolds. Lighting styles such as diffused lighting, silhouette, and back lighting are discussed, along with text styles like bold, graffiti, and neon. These elements can be combined to create diverse visual experiences in the generated videos.
In conclusion, the tutorial provides a comprehensive guide to using Runway Gen-3 Alpha effectively, from managing credits and refining prompts to exploring advanced features and directing prompts for optimal results. Viewers are encouraged to experiment with different settings, styles, and techniques to unleash the full creative potential of the platform. With detailed explanations and practical examples, the tutorial equips users with the knowledge and tools needed to navigate and excel in video generation using Runway Gen-3 Alpha.
|
__label__pos
| 0.991424 |
manpagez: man pages & more
html files: cairo
Home | html | info | man
Script Surfaces
Script Surfaces — Rendering to replayable scripts
Types and Values
Description
The script surface provides the ability to render to a native script that matches the cairo drawing model. The scripts can be replayed using tools under the util/cairo-script directory, or with cairo-perf-trace.
Functions
cairo_script_create ()
cairo_device_t *
cairo_script_create (const char *filename);
Creates a output device for emitting the script, used when creating the individual surfaces.
Parameters
filename
the name (path) of the file to write the script to
Returns
a pointer to the newly created device. The caller owns the surface and should call cairo_device_destroy() when done with it.
This function always returns a valid pointer, but it will return a pointer to a "nil" device if an error such as out of memory occurs. You can use cairo_device_status() to check for this.
Since: 1.12
cairo_script_create_for_stream ()
cairo_device_t *
cairo_script_create_for_stream (cairo_write_func_t write_func,
void *closure);
Creates a output device for emitting the script, used when creating the individual surfaces.
Parameters
write_func
callback function passed the bytes written to the script
closure
user data to be passed to the callback
Returns
a pointer to the newly created device. The caller owns the surface and should call cairo_device_destroy() when done with it.
This function always returns a valid pointer, but it will return a pointer to a "nil" device if an error such as out of memory occurs. You can use cairo_device_status() to check for this.
Since: 1.12
cairo_script_from_recording_surface ()
cairo_status_t
cairo_script_from_recording_surface (cairo_device_t *script,
cairo_surface_t *recording_surface);
Converts the record operations in recording_surface into a script.
Parameters
script
the script (output device)
recording_surface
the recording surface to replay
Returns
CAIRO_STATUS_SUCCESS on successful completion or an error code.
Since: 1.12
cairo_script_get_mode ()
cairo_script_mode_t
cairo_script_get_mode (cairo_device_t *script);
Queries the script for its current output mode.
Parameters
script
The script (output device) to query
Returns
the current output mode of the script
Since: 1.12
cairo_script_set_mode ()
void
cairo_script_set_mode (cairo_device_t *script,
cairo_script_mode_t mode);
Change the output mode of the script
Parameters
script
The script (output device)
mode
the new mode
Since: 1.12
cairo_script_surface_create ()
cairo_surface_t *
cairo_script_surface_create (cairo_device_t *script,
cairo_content_t content,
double width,
double height);
Create a new surface that will emit its rendering through script
Parameters
script
the script (output device)
content
the content of the surface
width
width in pixels
height
height in pixels
Returns
a pointer to the newly created surface. The caller owns the surface and should call cairo_surface_destroy() when done with it.
This function always returns a valid pointer, but it will return a pointer to a "nil" surface if an error such as out of memory occurs. You can use cairo_surface_status() to check for this.
Since: 1.12
cairo_script_surface_create_for_target ()
cairo_surface_t *
cairo_script_surface_create_for_target
(cairo_device_t *script,
cairo_surface_t *target);
Create a pxoy surface that will render to target and record the operations to device .
Parameters
script
the script (output device)
target
a target surface to wrap
Returns
a pointer to the newly created surface. The caller owns the surface and should call cairo_surface_destroy() when done with it.
This function always returns a valid pointer, but it will return a pointer to a "nil" surface if an error such as out of memory occurs. You can use cairo_surface_status() to check for this.
Since: 1.12
cairo_script_write_comment ()
void
cairo_script_write_comment (cairo_device_t *script,
const char *comment,
int len);
Emit a string verbatim into the script.
Parameters
script
the script (output device)
comment
the string to emit
len
the length of the sting to write, or -1 to use strlen()
Since: 1.12
Types and Values
CAIRO_HAS_SCRIPT_SURFACE
#define CAIRO_HAS_SCRIPT_SURFACE 1
Defined if the script surface backend is available. The script surface backend is always built in since 1.12.
Since: 1.12
enum cairo_script_mode_t
A set of script output variants.
Members
CAIRO_SCRIPT_MODE_ASCII
the output will be in readable text (default). (Since 1.12)
CAIRO_SCRIPT_MODE_BINARY
the output will use byte codes. (Since 1.12)
Since: 1.12
See Also
cairo_surface_t
© manpagez.com 2000-2017
Individual documents may contain additional copyright information.
|
__label__pos
| 0.65775 |
• How to Flush Memory Cache, Buffer Cache on Linux Server
Many times systems faced low memory issues of Linux systems running a while. The reason is that Linux uses so much memory for disk cache is because the RAM is wasted if it isn’t used. Cache is used to keep data to use frequently by the operating system. Reading data from cache if 1000’s time fas ...
阅读全文
作者:admin | 分类:Linux | 标签:
|
__label__pos
| 0.799056 |
Do statistics count ?
Discussion in 'other software & services' started by eyes-open, Jan 17, 2007.
Thread Status:
Not open for further replies.
1. eyes-open
eyes-open Registered Member
Joined:
May 13, 2005
Posts:
721
Have you ever played 'Top Trumps'™ ?
I think trading cards have a similar sort of layout - a graphic of the subject and then some facts & figures that accompany the layout.
In 'Top Trumps'™ a category from the card is chosen and then each player lays down their card ...... and the player whose card has the highest score in that category wins the round.
I mention the above because every now and then, a comparison thread starts and it's as if just such a game has begun. The subject of the deck is chosen - now that might be anti-spyware, registry cleaners, Hips programs - whatever ...... and pretty soon more players appear, fresh posts follow and the cards begin to be dealt face up.........Just like with the real game, you know everyone is looking on eagerly to see how the value of their card stacks up against other players offerings. Each of us hoping our card is a high scorer. That way we get to keep enjoying our hold on the card that represents our software choice, happy that for now at least, it's a good one....becoming slightly unsettled if the card representing our software isn't played or worse still, is played.......and scores badly.
Where the simile fails is often, the cards are simply played, the players stepping back to allow the others to look and then move on. It takes a moment or two to realise what's missing - actual, definable values, with which to judge which card wins which hand ? Why is your software, definitively better than the others ?
If for instance, you were going to create a set of statistics for product comparison - you might think the following categories worthy of inclusion:-
Size of install, CPU/ RAM usage, GUI, Cost, Support and of course, last but not least Efficacy (eg.detection/removal).
How is efficacy even measured in a way that each software type is compared on a like for like basis ? Where do you go for your comparison statistics ?
In some threads, despite them being contributed to by experienced folks, the best information you might get is little more than a hint, "light on resources", "great support", "good heuristics" etc ......... but how often, software for software, do you see this defined in a way that can be compared and tested ? Do you really get enough information to build the sort of stats that would make it possible for you to create a trading card that's worthwhile ? If not how are you selecting your software ?
Do you even have an expectation or standard to hold products to - or do you simply accept that when someone says somethings good, that it's good - and that as long as a product is benefiting from a momentum of approval, the statistics don't matter ?
How sure are you that the cards you've got still stack up well .......... and that your statistics are up to date ?
2. Mrkvonic
Mrkvonic Linux Systems Expert
Joined:
May 9, 2005
Posts:
8,697
Hello,
Major factor to take into consideration = fun.
If you're having fun, you have chosen wisely. After all, that's the purpose of life of intelligent creatures like cockroaches and barnacles and security geeks.
For me, the choices are:
Never detection/removal, because if the damn machine gets to the point where it thinks it's smarter than me, I'll blowtorch it. See who's smarter then.
Advice and comparisons are all nice and well, but they should be taken into consideration with certain amount of common sense, which varies from one person to another, be it the person giving advice or the one taking it.
It comes down to personal experience. And rather than trying to bring it down in numbers, it can be easily summed as an overall feeling. When the machine purs nicely and quietly and all the pieces fall into place.
Great support, heuristics etc... really differ from one person to another. Take any 'I need a firewall plz' thread. You'll get 43 answers from 32 different people, each one convinced his choice is the best. And they all really are.
Statistics don't matter for me. It's about experience. Fun.
Mrk
3. NGRhodes
NGRhodes Registered Member
Joined:
Jun 23, 2003
Posts:
2,331
Location:
West Yorkshire, UK
Stats - cant rely on them for anything, even my own data becomes outdated and/or erroneous as circumstance change.
There is no best.
There is only best for your needs.
Also no matter how good a product someone claims is it, I would always test it.
What runs well on someone else's machine might run terrible on your own.
4. Pedro
Pedro Registered Member
Joined:
Nov 2, 2006
Posts:
3,502
No one can digest it all. It's due to the fact that we're not perfectly racional beings. So it's only natural that so many opinions arise, since so many products are out there, with different features/ approaches. One cannot read and test it all and claim to know what the best product is. The concept of Bounded rationality (economics) describes this.
Also check this wiki-link about Herbert Simon, the author. For further reading, check transaction costs, from Williamson and Coase (related). This is only if you really want to delve into this part of Economics.
5. eyes-open
eyes-open Registered Member
Joined:
May 13, 2005
Posts:
721
Cheers all,
That's where it kinda tickles me and I agree, it does seem to be how it works for a huge swathe of people, myself included, to a degree, but isn't it just a little weird ?
I mean, beyond whether or not you believe a sort of program is necessary, if you do opt for choosing one, bringing it down to how you feel about it...... how does that work ? These are just computer programs aren't they, based on processing logic.... Just 1's & 0's, programmed to switch on and off according to instructions. How then do feelings become the yardstick for selection ?
I get we say that mileage may vary due to differing environments. Okay, that results in one individual experience, not necessarily being a model for the next persons - I can see that creates the rationale for then producing a scale based on the sum of users experiences.
It's all an understandable progression - and It makes sense too, that as assessments move away from the individual experience to an average experience, language is softened and made more accessible to accommodate a potentially larger user base. It all aids the warm & fuzzy feelings that can then create a sense of familiarity. That in turn can become brand loyalty and make it less likely a user will look around at other options.
On the other hand, lots of us have seen what happens when the user interface is suddenly changed and some users become unsettled - even though the actual engine may have improved - it is no longer what is familiar and once loyal users start to look around again.
It all appears to flow.......mostly I suppose, it remains reasonably safe because the software we're choosing from, has already attained a certain degree of credibility through testing & validation elsewhere. Still, if a computer developed it's AI to a point where it could make & express such decisions - "I chose your security cos it made me purr" would be really cool - but not necessarily all I had hoped for ..... :)
6. Ice_Czar
Ice_Czar Registered Member
Joined:
May 21, 2002
Posts:
696
Location:
Boulder Colorado
I dont focus on the minutia of direct software comparisons within a given class
but rather the synergistic effect of the different classes\technologies combined in comparison to the emerging threats.
Any individual testing is in that light invalid, at best describing a current state and the past.
Their value is simply to point out known flawed products\strategies, not guarantee against emerging threats
Most of us are only vaguely aware of the mechanics of programming with just empirical knowledge and interpreted analogies to work from. We get our "knowledge" of emerging threats the same way and judge the analogies against each other.
Thats why Im more interested in "best practices" and gaining a deeper understanding of actual programming \ exploitation.
I think of it as avoiding single point failure
interesting stuff ;)
bears more research
Last edited: Jan 18, 2007
7. eyes-open
eyes-open Registered Member
Joined:
May 13, 2005
Posts:
721
Hi Ice_Czar :)
I'm not 100% clear on where you stand. Are you saying through the medium of 'best practices' as you put it, you have chosen to work in a different way ? Maybe preferring emerging practices such as, maintaining a clean install through the use of virtual machines, online file checking, aligned with what's termed safe hex, partitioned data storage etc to a degree where the value of additional installed security software is as a whole, negligible to you.......... Therefore any assessment of onboard security software becomes redundant ?
If not, and you are still maintaining a fairly traditional response, then not to miss the point entirely I hope, but if you say you have no interest in as you put it the 'minutia of direct software comparisons within a given class' - how do you look to ensuring the integrity of the synergistic effect if you haven't first given any thought at all to the relative value of the components ? synergism might sometimes offer unexpected results, but in this context it's unlikely to be created with the aim of creating random results.
If thats true, then it seems equally unlikely for you not to at least have a minimum standard for something you deliberately install. Where that is the case I would have expected you would have to have a way of measuring the relative worth of any component.
8. Ice_Czar
Ice_Czar Registered Member
Joined:
May 21, 2002
Posts:
696
Location:
Boulder Colorado
Think you summed up my position in the first part rather well
I feel the value of comparative testing is of limited utility value
it weeds out the truly old and weak like a pack of wolves keep a herd of caribou healthy,
of course this pack of wolves is wear both white & black hats :p
But as a justification for purchasing one similar product over another because it detected a few more bits of nasty code presupposes its the sole defense for that vector.
As you point out I think redundancy is exactly the point, but not redundancy of technologies (multiple aps employing the same signatures and similar heuristics or behavior parameters)
Rather as you so eloquently put it cutting down the attack vectors in front, tricking or breaking the malware that does make it past the "traditional" detection phase, and above all indirect detection, where the actual subversion and what it is, isnt as important as knowing something has gone wrong and a recovery strategy needs to be quickly implemented.
I think its better to assume your going to have failures and subversions
What components fill the various niches in your strategy need to be robust growing and healthy, but they dont necessarily need to be the alpha leader.
9. eyes-open
eyes-open Registered Member
Joined:
May 13, 2005
Posts:
721
Cheers Ice_Czar - that's clear :thumb:
10. Rmus
Rmus Exploit Analyst
Joined:
Mar 16, 2005
Posts:
3,943
Location:
California
Security, first and foremost, is a state of mind. If you are convinced that you need a certain type of protection, then you will get it.
The important thing is to set up a strategy based on your perceived risks, then implement the tools you need. That puts your mind at peace. That is the important factor.
In seeking advice, for every person who has had a bad experience with a product, others will claim the opposite. Every system is different and reacts differently to any given product.
Careful users run their own tests and draw their own conclusions to compare with those of others.
By and large, most products in any given category provide good protection. It becomes a matter of choice based on factors that others have already mentioned.
EDIT: I meant to add that you bring up a good point about statistics. Not being good in math, I get headaches trying to sort out statistics, so I usually don't pay attention to them!
regards,
-rich
________________________________________________________________
"Talking About Security Can Lead To Anxiety, Panic, And Dread...
Or Cool Assessments, Common Sense And Practical Planning..."
--Bruce Schneier
Last edited: Jan 19, 2007
Loading...
Thread Status:
Not open for further replies.
|
__label__pos
| 0.69288 |
node package manager
Easy sharing. Manage teams and permissions with one click. Create a free org »
ble-scanner
BLE-Scanner
An easy to use ble-scanner (bluetooth smart / 4.0) for node. Requires a Linux OS with bluez stack tools (hciconfig, hcitool, hcidump) to be installed.
Usage
The ble-scanner is designed as a singleton class. It can be used as followed:
#require module
Scanner = require("ble-scanner");
# define input
device = "hci0";
callback = (packet) ->
# packet is an array with hex values
console.log "Received Packet: " + packet
# create new Scanner
bleScanner = new Scanner(device,callback);
The code above will result in every packet received to be logged to the console.
Notes
1. The device is used to make sure the specific device is up. The scan is not device specific.
2. The callback is handed an array with hex-values as strings. Interpreting the packet is not done by ble-scanner.
Known issues
1. HCITOOL does not terminate correctly.
|
__label__pos
| 0.911611 |
您现在的位置是: 网站首页 >Django >Vue+Django REST framework前后端分离生鲜电商 Django
【Vue+DRF生鲜电商】19.用户添加、删除收藏权限处理,根据商品id显示收藏,在Vue中实现收藏功能
admin2019年5月30日 17:03 Django | Vue 979人已围观
Vue+Django REST framework前后端分离生鲜电商简介 Vue+Django REST framework 打造前后端分离的生鲜电商项目(慕课网视频)。 Github地址:https://github.com/xyliurui/DjangoOnlineFreshSupermarket ; Django版本:2.2、djangorestframework:3.9.2。 前端Vue模板可以直接联系我拿。
### 用户添加、删除收藏记录权限问题 如果用户指定id删除收藏记录,如果这条收藏记录是其他人的,而不是当前登录用户的,仍然会被成功删除掉,这时候就涉及到一个权限问题:用户只能查看到自己的收藏记录,且只能删除自己的收藏记录。 #### 需要登录管理收藏记录IsAuthenticated 访问 https://www.django-rest-framework.org/api-guide/permissions/#isauthenticated 参考`IsAuthenticated` `IsAuthenticated`权限类将拒绝任何未经身份验证的用户的权限,否则将允许权限。 如果您希望您的API只允许注册用户访问,则此权限是合适的。 下面使用`IsAuthenticated`权限来限制只有用户登录后才能访问。 ```python # apps/user_operation/views.py from rest_framework.permissions import IsAuthenticated class UserFavViewSet(mixins.CreateModelMixin, mixins.DestroyModelMixin, mixins.ListModelMixin, viewsets.GenericViewSet): """ 用户收藏商品 取消收藏商品 显示收藏商品 """ queryset = UserFav.objects.all() serializer_class = UserFavSerializer permission_classes = (IsAuthenticated,) ```  当退出登录用户后,如果再访问 http://127.0.0.1:8000/userfavs/ 则会提示401错误。 但仅有`IsAuthenticated`权限是不够的,删除收藏记录还要判断这条记录的创建人是否是当前登录的用户,如果是才允许删除。 #### DRF自定义BasePermission验证所有者 DRF也提供了自定义权限功能,要实现自定义权限,覆盖`BasePermission`并实现以下方法之一或两者都实现: - `.has_permission(self, request, view)` - `.has_object_permission(self, request, view, obj)` 如果应该授予请求访问权,则方法应该返回`True`,否则返回`False`。 如果鉴权失败,自定义权限将引发一个`PermissionDenied`异常。要更改与异常关联的错误消息,直接在自定义权限上实现`message`属性。否则,将使用`PermissionDenied`中的`default_detail`属性。 可以查看 https://www.django-rest-framework.org/api-guide/permissions/#custom-permissions 的示例 在util文件夹下创建 permissions.py 文件,用户放置权限相关的配置。 ```python # utils/permissions.py from rest_framework import permissions class IsOwnerOrReadOnly(permissions.BasePermission): """ 对象级权限,只允许对象的所有者编辑它。 模型实例有一个 user 属性,指向用户的外键。 """ def has_object_permission(self, request, view, obj): # 读取权限允许任何请求,所以我们总是允许GET、HEAD或OPTIONS请求。 if request.method in permissions.SAFE_METHODS: return True # 实例必须有一个名为user的属性。 return obj.user == request.user ``` 以上的意思就是只有当对象的`user`和当前登录`user`一样,才返回`True`,表明鉴权通过。 然后再用户收藏ViewSet中添加该权限类 ```python # apps/user_operation/views.py from utils.permissions import IsOwnerOrReadOnly class UserFavViewSet(mixins.CreateModelMixin, mixins.DestroyModelMixin, mixins.ListModelMixin, viewsets.GenericViewSet): """ 用户收藏商品 取消收藏商品 显示收藏商品 """ queryset = UserFav.objects.all() serializer_class = UserFavSerializer permission_classes = (IsAuthenticated, IsOwnerOrReadOnly) ``` #### 只能查看自己的收藏记录 还有一个问题就是,获取用户收藏时,不能获取所有的收藏记录,只获取到当前用户的收藏记录。所以要重载`get_queryset()`方法,过滤当前用户。 ```python # apps/user_operation/views.py class UserFavViewSet(mixins.CreateModelMixin, mixins.DestroyModelMixin, mixins.ListModelMixin, viewsets.GenericViewSet): """ 用户收藏商品 取消收藏商品 显示收藏商品 """ queryset = UserFav.objects.all() serializer_class = UserFavSerializer permission_classes = (IsAuthenticated, IsOwnerOrReadOnly) def get_queryset(self): # 过滤当前用户的收藏记录 return self.queryset.filter(user=self.request.user) ``` 现在访问 http://127.0.0.1:8000/userfavs/ 给当前用户增加几个收藏  在后台将任意一个收藏记录修改为其他用户,比如这儿`id=5`的, http://127.0.0.1:8000/admin/user_operation/userfav/5/change/ 改为另一个用户  现在序列化时只会显示当前登录用户的收藏记录了。 #### 测试取消全局登录认证  现在退出当前登录用户,最好重新打开浏览器,然后用工具请求删除功能,比如删除`id=4`的收藏记录  点击send之后,因为权限类中配置了`IsAuthenticated`,就会弹出登录框,取消就会出现401的错误。如果如果帐密后,那么该记录就会被删除  登陆之后,该记录就会被成功删除  刷新 http://127.0.0.1:8000/userfavs/ 指定id的记录就消失了。  这儿直接可以输入账号密码就完成登录,因为在 settings.py 中`REST_FRAMEWORK`配置了`'rest_framework.authentication.BasicAuthentication',`(即输入用户名密码认证模式) 注释掉全局token认证 ```python # DjangoOnlineFreshSupermarket/settings.py REST_FRAMEWORK = { # 'DEFAULT_PAGINATION_CLASS': 'rest_framework.pagination.PageNumberPagination', # 'PAGE_SIZE': 5, 'DEFAULT_AUTHENTICATION_CLASSES': ( 'rest_framework.authentication.BasicAuthentication', 'rest_framework.authentication.SessionAuthentication', # 上面两个用于DRF基本验证 # 'rest_framework.authentication.TokenAuthentication', # TokenAuthentication,取消全局token,放在视图中进行 # 'rest_framework_simplejwt.authentication.JWTAuthentication', # djangorestframework_simplejwt JWT认证 ) } ``` `token`认证最好是放在view里面去,不要配置在全局变量中,如果再前端请求中,每一个`request`都加入`token`,这个`token`恰好过期了,那么用户在访问category、goods这种公开数据时,就会抛异常,连商品的列表页都访问不了了。 #### 配置局部JWTAuthentication认证 需要将`JWTAuthentication`配置到需要的view中,这才是一种比较安全的做法,比如在用户收藏ViewSet中配置 ```python # apps/user_operation/views.py from rest_framework_simplejwt.authentication import JWTAuthentication class UserFavViewSet(mixins.CreateModelMixin, mixins.DestroyModelMixin, mixins.ListModelMixin, viewsets.GenericViewSet): """ 用户收藏商品 取消收藏商品 显示收藏商品 """ queryset = UserFav.objects.all() serializer_class = UserFavSerializer permission_classes = (IsAuthenticated, IsOwnerOrReadOnly) authentication_classes = (JWTAuthentication,) # 配置登录认证 def get_queryset(self): # 过滤当前用户的收藏记录 return self.queryset.filter(user=self.request.user) ``` 这样就不会在全局做token验证了。用户在发送JWT token时,如果是`GoodsListViewSet`,那么商品列表视图就不会调用这个`JWTAuthentication`,不会抛异常。只有当访问`UserFavViewSet`这种配置了`authentication_classes`,才会进行token验证。 现在来删除`id=3`的收藏数据,会出现401错误,表示需要用户登录  熟练需要获取token,将用户名密码提交到 http://127.0.0.1:8000/login/ 获取  可以得到 ```json { "refresh": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ0b2tlbl90eXBlIjoicmVmcmVzaCIsImV4cCI6MTU1ODUxOTIyNSwianRpIjoiOGE1MWY4NmNlMTZlNDZmMjk4ODJmZmU0ZjExNjE0ODciLCJ1c2VyX2lkIjoxfQ.t31c-RiD3mjq3Fb3YvvDhZi_Yd5vcQl8f4OfTU0_oLE", "access": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ0b2tlbl90eXBlIjoiYWNjZXNzIiwiZXhwIjoxNTU3ODI4MDI1LCJqdGkiOiJiYTEzMDYzNjMxNTU0NzFkYTE3ODNlN2FmYWMwODhiNCIsInVzZXJfaWQiOjF9.L_ZmXyv0wti9HImWDM5qcHVU7LTwBO--7JFGLb7l9rU" } ``` 然后通过这个token来请求,需要添加Header,键为`Authorization`,值为`Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ0b2tlbl90eXBlIjoiYWNjZXNzIiwiZXhwIjoxNTU3ODI4MDI1LCJqdGkiOiJiYTEzMDYzNjMxNTU0NzFkYTE3ODNlN2FmYWMwODhiNCIsInVzZXJfaWQiOjF9.L_ZmXyv0wti9HImWDM5qcHVU7LTwBO--7JFGLb7l9rU`  就可以成功删除记录。 如果不是删除当前用户创建的记录,则会提示404错误  #### 配置局部SessionAuthentication认证 访问 http://127.0.0.1:8000/userfavs/ 并点击右上角的登录  但仍然会显示`"detail": "身份认证信息未提供。"`,因为在`authentication_classes = (JWTAuthentication,)`中只使用了`JWTAuthentication`,表明只支持JWT用户认证,如果想要DRF Api中可以通过认证,还需要添加`SessionAuthentication`,表明支持session认证模式。 ```python # apps/user_operation/views.py from rest_framework.authentication import SessionAuthentication class UserFavViewSet(mixins.CreateModelMixin, mixins.DestroyModelMixin, mixins.ListModelMixin, viewsets.GenericViewSet): """ 用户收藏商品 取消收藏商品 显示收藏商品 """ queryset = UserFav.objects.all() serializer_class = UserFavSerializer permission_classes = (IsAuthenticated, IsOwnerOrReadOnly) authentication_classes = (JWTAuthentication, SessionAuthentication) # 配置登录认证:支持JWT认证和DRF基本认证 def get_queryset(self): # 过滤当前用户的收藏记录 return self.queryset.filter(user=self.request.user) ```  ### 显示具体收藏,根据商品id 首先将ViewSet继承`mixins.RetrieveModelMixin` `UserFavViewSet`继承的`viewsets.GenericViewSet`又继承了`generics.GenericAPIView`,其中有一个`lookup_field = 'pk'`属性(如果想使用pk以外的对象查找,设置`lookup_field`) 访问 https://www.django-rest-framework.org/api-guide/generic-views/#genericapiview 可以查看相关的属性 以下属性控制着基本视图的行为。 - `queryset`:用于从视图返回对象的查询结果集。通常,你必须设置此属性或者重写 `get_queryset()` 方法。如果你重写了一个视图的方法,重要的是你应该调用 `get_queryset()` 方法而不是直接访问该属性,因为 `queryset` 将被计算一次,这些结果将为后续请求缓存起来。 - `serializer_class`:用于验证和反序列化输入以及用于序列化输出的Serializer类。 通常,你必须设置此属性或者重写`get_serializer_class()` 方法。 - `lookup_field` :用于执行各个model实例的对象查找的model字段。默认为 `'pk'`。 请注意,在使用超链接API时,如果需要使用自定义的值,你需要确保在API视图*和*序列化类*都*设置查找字段。 - `lookup_url_kwarg` :应用于对象查找的URL关键字参数。它的 URL conf 应该包括一个与这个值相对应的关键字参数。如果取消设置,默认情况下使用与 `lookup_field`相同的值。 将项目的`lookup_field`修改为商品的id,因为对于当前登录用户来说,用户收藏商品是唯一的,它是根据`get_queryset(self)`筛选后搜索的。 ```python # apps/user_operation/views.py class UserFavViewSet(mixins.CreateModelMixin, mixins.DestroyModelMixin, mixins.ListModelMixin, mixins.RetrieveModelMixin, viewsets.GenericViewSet): """ 用户收藏商品 取消收藏商品 显示收藏商品列表 根据商品id显示收藏详情 """ queryset = UserFav.objects.all() serializer_class = UserFavSerializer permission_classes = (IsAuthenticated, IsOwnerOrReadOnly) authentication_classes = (JWTAuthentication, SessionAuthentication) # 配置登录认证:支持JWT认证和DRF基本认证 lookup_field = 'goods_id' def get_queryset(self): # 过滤当前用户的收藏记录 return self.queryset.filter(user=self.request.user) ``` 测试下是否是根据`goods_id`搜索 如果直接搜索id,则搜索不到结果   就可以按照商品的id显示详情。可用性高,用户进入商品详情页,用户要去查询这个商品有没有被收藏,这个url里面就可以直接填写goods的`id`,不需要知道当时数据库里面保存的数据id是什么。直接根据商品的id去查询收藏,如果有记录,则页面就显示已收藏的信息,如果没被记录,表明商品没被收藏。 这里按照`goods.id`进行查找,对于同一个商品,可能会被很多人收藏,但并不会造成查询出错,因为商品和用户一起构成了唯一性,而且`lookup_field`字段是在`get_queryset(self)`过滤之后的结果进行查找,也就是过滤当前登录用户,保证了唯一性,所以不会出错。 ### Vue联调 在商品详情页,如果用户没有登录的情况,那么收藏按钮的状态应该是未收藏。  这时候是无法获取用户的。Vue逻辑如下 #### 获取商品收藏状态 用户进入详情页,也就是 src/views/productDetail/productDetail.vue 组件,获取商品的id,从cookie中找`token` ```JavaScript // src/views/productDetail/productDetail.vue created() { this.productId = this.$route.params.productId; var productId = this.productId; if (cookie.getCookie('token')) { getFav(productId).then((response) => { this.hasFav = true }).catch(function (error) { console.log(error); }); } this.getDetails(); }, ``` 如果找到这个`token`,就调用`getFav(productId)`查询该商品是否被收藏。这里面调用请求后端的接口。 ```JavaScript // src/api/api.js //判断是否收藏 export const getFav = goodsId => { return axios.get(`${local_host}/userfavs/` + goodsId + '/') }; ``` 如果获取的状态码为200,也就是已收藏状态(因为未获取到状态码为404),则将`hasFav`设置为`true`,看下面的判断逻辑 ```html <!-- src/views/productDetail/productDetail.vue --> <a v-if="hasFav" id="fav-btn" class="graybtn" @click="deleteCollect"> <i class="iconfont"></i>已收藏</a> <a v-else class="graybtn" @click="addCollect"> <i class="iconfont"></i>收藏</a> ``` 如果为`true`,则显示已收藏,否则显示收藏。 #### 删除收藏点击 用户点击已收藏按钮时,则会执行`@click="deleteCollect"`操作 ```JavaScript // src/views/productDetail/productDetail.vue deleteCollect() { //删除收藏 delFav(this.productId).then((response) => { //console.log(response.data); this.hasFav = false }).catch(function (error) { console.log(error); }); }, ``` 在这个方法中,调用删除收藏的接口,如果删除成功,状态码也是204,则将`hasFav`置为`false` ```JavaScript // src/api/api.js //取消收藏 export const delFav = goodsId => { return axios.delete(`${local_host}/userfavs/` + goodsId + '/') }; ``` #### 添加收藏点击 如果商品未收藏,用户点击该按钮时,执行`@click="addCollect"` ```JavaScript // src/views/productDetail/productDetail.vue addCollect() { //加入收藏 addFav({ goods: this.productId }).then((response) => { //console.log(response.data); this.hasFav = true; alert('已成功加入收藏夹'); }).catch(function (error) { console.log(error); }); }, ``` 这里面会调用收藏接口 ```JavaScript // src/api/api.js //收藏 export const addFav = params => { return axios.post(`${local_host}/userfavs/`, params) }; ``` 向后台POST`{goods: this.productId}`,如果状态码为2xx,则收藏成功。`hasFav`置为`true` 登录之后打开调试,然后点击收藏  会收到弹框提示。按钮就变为已收藏了。  然后取消收藏,状态码为204  刷新 http://127.0.0.1:8000/admin/user_operation/userfav/ 之前的收藏已经消失了。 
很赞哦! (0)
文章交流
• emoji
0人参与,0条评论
当前用户
未登录,点击 登录
站点信息
• 建站时间:网站已运行1198天
• 系统信息:Linux
• 后台程序:Python: 3.8.10
• 网站框架:Django: 3.2.6
• 文章统计:256 篇
• 文章评论:54 条
• 腾讯分析网站概况-腾讯分析
• 百度统计网站概况-百度统计
• 公众号:微信扫描二维码,关注我们
• QQ群:QQ加群,下载网站的学习源码
返回
顶部
标题 换行 登录
网站
|
__label__pos
| 0.676953 |
Index: stable/12/sys/dev/mrsas/mrsas.c =================================================================== --- stable/12/sys/dev/mrsas/mrsas.c (revision 349208) +++ stable/12/sys/dev/mrsas/mrsas.c (revision 349209) @@ -1,5047 +1,5081 @@ /* * Copyright (c) 2015, AVAGO Tech. All rights reserved. Author: Marian Choy * Copyright (c) 2014, LSI Corp. All rights reserved. Author: Marian Choy * Support: [email protected] * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. 2. Redistributions * in binary form must reproduce the above copyright notice, this list of * conditions and the following disclaimer in the documentation and/or other * materials provided with the distribution. 3. Neither the name of the * nor the names of its contributors may be used to endorse or * promote products derived from this software without specific prior written * permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * * The views and conclusions contained in the software and documentation are * those of the authors and should not be interpreted as representing * official policies,either expressed or implied, of the FreeBSD Project. * * Send feedback to: Mail to: AVAGO TECHNOLOGIES 1621 * Barber Lane, Milpitas, CA 95035 ATTN: MegaRaid FreeBSD * */ #include __FBSDID("$FreeBSD$"); #include #include #include #include #include #include #include #include #include #include /* * Function prototypes */ static d_open_t mrsas_open; static d_close_t mrsas_close; static d_read_t mrsas_read; static d_write_t mrsas_write; static d_ioctl_t mrsas_ioctl; static d_poll_t mrsas_poll; static void mrsas_ich_startup(void *arg); static struct mrsas_mgmt_info mrsas_mgmt_info; static struct mrsas_ident *mrsas_find_ident(device_t); static int mrsas_setup_msix(struct mrsas_softc *sc); static int mrsas_allocate_msix(struct mrsas_softc *sc); static void mrsas_shutdown_ctlr(struct mrsas_softc *sc, u_int32_t opcode); static void mrsas_flush_cache(struct mrsas_softc *sc); static void mrsas_reset_reply_desc(struct mrsas_softc *sc); static void mrsas_ocr_thread(void *arg); static int mrsas_get_map_info(struct mrsas_softc *sc); static int mrsas_get_ld_map_info(struct mrsas_softc *sc); static int mrsas_sync_map_info(struct mrsas_softc *sc); static int mrsas_get_pd_list(struct mrsas_softc *sc); static int mrsas_get_ld_list(struct mrsas_softc *sc); static int mrsas_setup_irq(struct mrsas_softc *sc); static int mrsas_alloc_mem(struct mrsas_softc *sc); static int mrsas_init_fw(struct mrsas_softc *sc); static int mrsas_setup_raidmap(struct mrsas_softc *sc); static void megasas_setup_jbod_map(struct mrsas_softc *sc); static int megasas_sync_pd_seq_num(struct mrsas_softc *sc, boolean_t pend); static int mrsas_clear_intr(struct mrsas_softc *sc); static int mrsas_get_ctrl_info(struct mrsas_softc *sc); static void mrsas_update_ext_vd_details(struct mrsas_softc *sc); static int mrsas_issue_blocked_abort_cmd(struct mrsas_softc *sc, struct mrsas_mfi_cmd *cmd_to_abort); static void mrsas_get_pd_info(struct mrsas_softc *sc, u_int16_t device_id); static struct mrsas_softc * mrsas_get_softc_instance(struct cdev *dev, u_long cmd, caddr_t arg); u_int32_t mrsas_read_reg_with_retries(struct mrsas_softc *sc, int offset); u_int32_t mrsas_read_reg(struct mrsas_softc *sc, int offset); u_int8_t mrsas_build_mptmfi_passthru(struct mrsas_softc *sc, struct mrsas_mfi_cmd *mfi_cmd); void mrsas_complete_outstanding_ioctls(struct mrsas_softc *sc); int mrsas_transition_to_ready(struct mrsas_softc *sc, int ocr); int mrsas_init_adapter(struct mrsas_softc *sc); int mrsas_alloc_mpt_cmds(struct mrsas_softc *sc); int mrsas_alloc_ioc_cmd(struct mrsas_softc *sc); int mrsas_alloc_ctlr_info_cmd(struct mrsas_softc *sc); int mrsas_ioc_init(struct mrsas_softc *sc); int mrsas_bus_scan(struct mrsas_softc *sc); int mrsas_issue_dcmd(struct mrsas_softc *sc, struct mrsas_mfi_cmd *cmd); int mrsas_issue_polled(struct mrsas_softc *sc, struct mrsas_mfi_cmd *cmd); int mrsas_reset_ctrl(struct mrsas_softc *sc, u_int8_t reset_reason); int mrsas_wait_for_outstanding(struct mrsas_softc *sc, u_int8_t check_reason); int mrsas_complete_cmd(struct mrsas_softc *sc, u_int32_t MSIxIndex); int mrsas_reset_targets(struct mrsas_softc *sc); int mrsas_issue_blocked_cmd(struct mrsas_softc *sc, struct mrsas_mfi_cmd *cmd); int mrsas_alloc_tmp_dcmd(struct mrsas_softc *sc, struct mrsas_tmp_dcmd *tcmd, int size); void mrsas_release_mfi_cmd(struct mrsas_mfi_cmd *cmd); void mrsas_wakeup(struct mrsas_softc *sc, struct mrsas_mfi_cmd *cmd); void mrsas_complete_aen(struct mrsas_softc *sc, struct mrsas_mfi_cmd *cmd); void mrsas_complete_abort(struct mrsas_softc *sc, struct mrsas_mfi_cmd *cmd); void mrsas_disable_intr(struct mrsas_softc *sc); void mrsas_enable_intr(struct mrsas_softc *sc); void mrsas_free_ioc_cmd(struct mrsas_softc *sc); void mrsas_free_mem(struct mrsas_softc *sc); void mrsas_free_tmp_dcmd(struct mrsas_tmp_dcmd *tmp); void mrsas_isr(void *arg); void mrsas_teardown_intr(struct mrsas_softc *sc); void mrsas_addr_cb(void *arg, bus_dma_segment_t *segs, int nsegs, int error); void mrsas_kill_hba(struct mrsas_softc *sc); void mrsas_aen_handler(struct mrsas_softc *sc); void mrsas_write_reg(struct mrsas_softc *sc, int offset, u_int32_t value); void mrsas_fire_cmd(struct mrsas_softc *sc, u_int32_t req_desc_lo, u_int32_t req_desc_hi); void mrsas_free_ctlr_info_cmd(struct mrsas_softc *sc); void mrsas_complete_mptmfi_passthru(struct mrsas_softc *sc, struct mrsas_mfi_cmd *cmd, u_int8_t status); struct mrsas_mfi_cmd *mrsas_get_mfi_cmd(struct mrsas_softc *sc); MRSAS_REQUEST_DESCRIPTOR_UNION *mrsas_build_mpt_cmd (struct mrsas_softc *sc, struct mrsas_mfi_cmd *cmd); extern int mrsas_cam_attach(struct mrsas_softc *sc); extern void mrsas_cam_detach(struct mrsas_softc *sc); extern void mrsas_cmd_done(struct mrsas_softc *sc, struct mrsas_mpt_cmd *cmd); extern void mrsas_free_frame(struct mrsas_softc *sc, struct mrsas_mfi_cmd *cmd); extern int mrsas_alloc_mfi_cmds(struct mrsas_softc *sc); extern struct mrsas_mpt_cmd *mrsas_get_mpt_cmd(struct mrsas_softc *sc); extern int mrsas_passthru(struct mrsas_softc *sc, void *arg, u_long ioctlCmd); extern uint8_t MR_ValidateMapInfo(struct mrsas_softc *sc); extern u_int16_t MR_GetLDTgtId(u_int32_t ld, MR_DRV_RAID_MAP_ALL * map); extern MR_LD_RAID *MR_LdRaidGet(u_int32_t ld, MR_DRV_RAID_MAP_ALL * map); extern void mrsas_xpt_freeze(struct mrsas_softc *sc); extern void mrsas_xpt_release(struct mrsas_softc *sc); extern MRSAS_REQUEST_DESCRIPTOR_UNION * mrsas_get_request_desc(struct mrsas_softc *sc, u_int16_t index); extern int mrsas_bus_scan_sim(struct mrsas_softc *sc, struct cam_sim *sim); static int mrsas_alloc_evt_log_info_cmd(struct mrsas_softc *sc); static void mrsas_free_evt_log_info_cmd(struct mrsas_softc *sc); void mrsas_release_mpt_cmd(struct mrsas_mpt_cmd *cmd); void mrsas_map_mpt_cmd_status(struct mrsas_mpt_cmd *cmd, union ccb *ccb_ptr, u_int8_t status, u_int8_t extStatus, u_int32_t data_length, u_int8_t *sense); void mrsas_write_64bit_req_desc(struct mrsas_softc *sc, u_int32_t req_desc_lo, u_int32_t req_desc_hi); SYSCTL_NODE(_hw, OID_AUTO, mrsas, CTLFLAG_RD, 0, "MRSAS Driver Parameters"); /* * PCI device struct and table * */ typedef struct mrsas_ident { uint16_t vendor; uint16_t device; uint16_t subvendor; uint16_t subdevice; const char *desc; } MRSAS_CTLR_ID; MRSAS_CTLR_ID device_table[] = { {0x1000, MRSAS_TBOLT, 0xffff, 0xffff, "AVAGO Thunderbolt SAS Controller"}, {0x1000, MRSAS_INVADER, 0xffff, 0xffff, "AVAGO Invader SAS Controller"}, {0x1000, MRSAS_FURY, 0xffff, 0xffff, "AVAGO Fury SAS Controller"}, {0x1000, MRSAS_INTRUDER, 0xffff, 0xffff, "AVAGO Intruder SAS Controller"}, {0x1000, MRSAS_INTRUDER_24, 0xffff, 0xffff, "AVAGO Intruder_24 SAS Controller"}, {0x1000, MRSAS_CUTLASS_52, 0xffff, 0xffff, "AVAGO Cutlass_52 SAS Controller"}, {0x1000, MRSAS_CUTLASS_53, 0xffff, 0xffff, "AVAGO Cutlass_53 SAS Controller"}, {0x1000, MRSAS_VENTURA, 0xffff, 0xffff, "AVAGO Ventura SAS Controller"}, {0x1000, MRSAS_CRUSADER, 0xffff, 0xffff, "AVAGO Crusader SAS Controller"}, {0x1000, MRSAS_HARPOON, 0xffff, 0xffff, "AVAGO Harpoon SAS Controller"}, {0x1000, MRSAS_TOMCAT, 0xffff, 0xffff, "AVAGO Tomcat SAS Controller"}, {0x1000, MRSAS_VENTURA_4PORT, 0xffff, 0xffff, "AVAGO Ventura_4Port SAS Controller"}, {0x1000, MRSAS_CRUSADER_4PORT, 0xffff, 0xffff, "AVAGO Crusader_4Port SAS Controller"}, {0x1000, MRSAS_AERO_10E0, 0xffff, 0xffff, "BROADCOM AERO-10E0 SAS Controller"}, {0x1000, MRSAS_AERO_10E1, 0xffff, 0xffff, "BROADCOM AERO-10E1 SAS Controller"}, {0x1000, MRSAS_AERO_10E2, 0xffff, 0xffff, "BROADCOM AERO-10E2 SAS Controller"}, {0x1000, MRSAS_AERO_10E3, 0xffff, 0xffff, "BROADCOM AERO-10E3 SAS Controller"}, {0x1000, MRSAS_AERO_10E4, 0xffff, 0xffff, "BROADCOM AERO-10E4 SAS Controller"}, {0x1000, MRSAS_AERO_10E5, 0xffff, 0xffff, "BROADCOM AERO-10E5 SAS Controller"}, {0x1000, MRSAS_AERO_10E6, 0xffff, 0xffff, "BROADCOM AERO-10E6 SAS Controller"}, {0x1000, MRSAS_AERO_10E7, 0xffff, 0xffff, "BROADCOM AERO-10E7 SAS Controller"}, {0, 0, 0, 0, NULL} }; /* * Character device entry points * */ static struct cdevsw mrsas_cdevsw = { .d_version = D_VERSION, .d_open = mrsas_open, .d_close = mrsas_close, .d_read = mrsas_read, .d_write = mrsas_write, .d_ioctl = mrsas_ioctl, .d_poll = mrsas_poll, .d_name = "mrsas", }; MALLOC_DEFINE(M_MRSAS, "mrsasbuf", "Buffers for the MRSAS driver"); /* * In the cdevsw routines, we find our softc by using the si_drv1 member of * struct cdev. We set this variable to point to our softc in our attach * routine when we create the /dev entry. */ int mrsas_open(struct cdev *dev, int oflags, int devtype, struct thread *td) { struct mrsas_softc *sc; sc = dev->si_drv1; return (0); } int mrsas_close(struct cdev *dev, int fflag, int devtype, struct thread *td) { struct mrsas_softc *sc; sc = dev->si_drv1; return (0); } int mrsas_read(struct cdev *dev, struct uio *uio, int ioflag) { struct mrsas_softc *sc; sc = dev->si_drv1; return (0); } int mrsas_write(struct cdev *dev, struct uio *uio, int ioflag) { struct mrsas_softc *sc; sc = dev->si_drv1; return (0); } u_int32_t mrsas_read_reg_with_retries(struct mrsas_softc *sc, int offset) { u_int32_t i = 0, ret_val; if (sc->is_aero) { do { ret_val = mrsas_read_reg(sc, offset); i++; } while(ret_val == 0 && i < 3); } else ret_val = mrsas_read_reg(sc, offset); return ret_val; } /* * Register Read/Write Functions * */ void mrsas_write_reg(struct mrsas_softc *sc, int offset, u_int32_t value) { bus_space_tag_t bus_tag = sc->bus_tag; bus_space_handle_t bus_handle = sc->bus_handle; bus_space_write_4(bus_tag, bus_handle, offset, value); } u_int32_t mrsas_read_reg(struct mrsas_softc *sc, int offset) { bus_space_tag_t bus_tag = sc->bus_tag; bus_space_handle_t bus_handle = sc->bus_handle; return ((u_int32_t)bus_space_read_4(bus_tag, bus_handle, offset)); } /* * Interrupt Disable/Enable/Clear Functions * */ void mrsas_disable_intr(struct mrsas_softc *sc) { u_int32_t mask = 0xFFFFFFFF; u_int32_t status; sc->mask_interrupts = 1; mrsas_write_reg(sc, offsetof(mrsas_reg_set, outbound_intr_mask), mask); /* Dummy read to force pci flush */ status = mrsas_read_reg(sc, offsetof(mrsas_reg_set, outbound_intr_mask)); } void mrsas_enable_intr(struct mrsas_softc *sc) { u_int32_t mask = MFI_FUSION_ENABLE_INTERRUPT_MASK; u_int32_t status; sc->mask_interrupts = 0; mrsas_write_reg(sc, offsetof(mrsas_reg_set, outbound_intr_status), ~0); status = mrsas_read_reg(sc, offsetof(mrsas_reg_set, outbound_intr_status)); mrsas_write_reg(sc, offsetof(mrsas_reg_set, outbound_intr_mask), ~mask); status = mrsas_read_reg(sc, offsetof(mrsas_reg_set, outbound_intr_mask)); } static int mrsas_clear_intr(struct mrsas_softc *sc) { u_int32_t status; /* Read received interrupt */ status = mrsas_read_reg_with_retries(sc, offsetof(mrsas_reg_set, outbound_intr_status)); /* Not our interrupt, so just return */ if (!(status & MFI_FUSION_ENABLE_INTERRUPT_MASK)) return (0); /* We got a reply interrupt */ return (1); } /* * PCI Support Functions * */ static struct mrsas_ident * mrsas_find_ident(device_t dev) { struct mrsas_ident *pci_device; for (pci_device = device_table; pci_device->vendor != 0; pci_device++) { if ((pci_device->vendor == pci_get_vendor(dev)) && (pci_device->device == pci_get_device(dev)) && ((pci_device->subvendor == pci_get_subvendor(dev)) || (pci_device->subvendor == 0xffff)) && ((pci_device->subdevice == pci_get_subdevice(dev)) || (pci_device->subdevice == 0xffff))) return (pci_device); } return (NULL); } static int mrsas_probe(device_t dev) { static u_int8_t first_ctrl = 1; struct mrsas_ident *id; if ((id = mrsas_find_ident(dev)) != NULL) { if (first_ctrl) { printf("AVAGO MegaRAID SAS FreeBSD mrsas driver version: %s\n", MRSAS_VERSION); first_ctrl = 0; } device_set_desc(dev, id->desc); /* between BUS_PROBE_DEFAULT and BUS_PROBE_LOW_PRIORITY */ return (-30); } return (ENXIO); } /* * mrsas_setup_sysctl: setup sysctl values for mrsas * input: Adapter instance soft state * * Setup sysctl entries for mrsas driver. */ static void mrsas_setup_sysctl(struct mrsas_softc *sc) { struct sysctl_ctx_list *sysctl_ctx = NULL; struct sysctl_oid *sysctl_tree = NULL; char tmpstr[80], tmpstr2[80]; /* * Setup the sysctl variable so the user can change the debug level * on the fly. */ snprintf(tmpstr, sizeof(tmpstr), "MRSAS controller %d", device_get_unit(sc->mrsas_dev)); snprintf(tmpstr2, sizeof(tmpstr2), "%d", device_get_unit(sc->mrsas_dev)); sysctl_ctx = device_get_sysctl_ctx(sc->mrsas_dev); if (sysctl_ctx != NULL) sysctl_tree = device_get_sysctl_tree(sc->mrsas_dev); if (sysctl_tree == NULL) { sysctl_ctx_init(&sc->sysctl_ctx); sc->sysctl_tree = SYSCTL_ADD_NODE(&sc->sysctl_ctx, SYSCTL_STATIC_CHILDREN(_hw_mrsas), OID_AUTO, tmpstr2, CTLFLAG_RD, 0, tmpstr); if (sc->sysctl_tree == NULL) return; sysctl_ctx = &sc->sysctl_ctx; sysctl_tree = sc->sysctl_tree; } SYSCTL_ADD_UINT(sysctl_ctx, SYSCTL_CHILDREN(sysctl_tree), OID_AUTO, "disable_ocr", CTLFLAG_RW, &sc->disableOnlineCtrlReset, 0, "Disable the use of OCR"); SYSCTL_ADD_STRING(sysctl_ctx, SYSCTL_CHILDREN(sysctl_tree), OID_AUTO, "driver_version", CTLFLAG_RD, MRSAS_VERSION, strlen(MRSAS_VERSION), "driver version"); SYSCTL_ADD_INT(sysctl_ctx, SYSCTL_CHILDREN(sysctl_tree), OID_AUTO, "reset_count", CTLFLAG_RD, &sc->reset_count, 0, "number of ocr from start of the day"); SYSCTL_ADD_INT(sysctl_ctx, SYSCTL_CHILDREN(sysctl_tree), OID_AUTO, "fw_outstanding", CTLFLAG_RD, &sc->fw_outstanding.val_rdonly, 0, "FW outstanding commands"); SYSCTL_ADD_INT(sysctl_ctx, SYSCTL_CHILDREN(sysctl_tree), OID_AUTO, "io_cmds_highwater", CTLFLAG_RD, &sc->io_cmds_highwater, 0, "Max FW outstanding commands"); SYSCTL_ADD_UINT(sysctl_ctx, SYSCTL_CHILDREN(sysctl_tree), OID_AUTO, "mrsas_debug", CTLFLAG_RW, &sc->mrsas_debug, 0, "Driver debug level"); SYSCTL_ADD_UINT(sysctl_ctx, SYSCTL_CHILDREN(sysctl_tree), OID_AUTO, "mrsas_io_timeout", CTLFLAG_RW, &sc->mrsas_io_timeout, 0, "Driver IO timeout value in mili-second."); SYSCTL_ADD_UINT(sysctl_ctx, SYSCTL_CHILDREN(sysctl_tree), OID_AUTO, "mrsas_fw_fault_check_delay", CTLFLAG_RW, &sc->mrsas_fw_fault_check_delay, 0, "FW fault check thread delay in seconds. "); SYSCTL_ADD_INT(sysctl_ctx, SYSCTL_CHILDREN(sysctl_tree), OID_AUTO, "reset_in_progress", CTLFLAG_RD, &sc->reset_in_progress, 0, "ocr in progress status"); SYSCTL_ADD_UINT(sysctl_ctx, SYSCTL_CHILDREN(sysctl_tree), OID_AUTO, "block_sync_cache", CTLFLAG_RW, &sc->block_sync_cache, 0, "Block SYNC CACHE at driver. "); SYSCTL_ADD_UINT(sysctl_ctx, SYSCTL_CHILDREN(sysctl_tree), OID_AUTO, "stream detection", CTLFLAG_RW, &sc->drv_stream_detection, 0, "Disable/Enable Stream detection. "); SYSCTL_ADD_INT(sysctl_ctx, SYSCTL_CHILDREN(sysctl_tree), OID_AUTO, "prp_count", CTLFLAG_RD, &sc->prp_count.val_rdonly, 0, "Number of IOs for which PRPs are built"); SYSCTL_ADD_INT(sysctl_ctx, SYSCTL_CHILDREN(sysctl_tree), OID_AUTO, "SGE holes", CTLFLAG_RD, &sc->sge_holes.val_rdonly, 0, "Number of IOs with holes in SGEs"); } /* * mrsas_get_tunables: get tunable parameters. * input: Adapter instance soft state * * Get tunable parameters. This will help to debug driver at boot time. */ static void mrsas_get_tunables(struct mrsas_softc *sc) { char tmpstr[80]; /* XXX default to some debugging for now */ sc->mrsas_debug = (MRSAS_FAULT | MRSAS_OCR | MRSAS_INFO | MRSAS_TRACE | MRSAS_AEN); sc->mrsas_io_timeout = MRSAS_IO_TIMEOUT; sc->mrsas_fw_fault_check_delay = 1; sc->reset_count = 0; sc->reset_in_progress = 0; sc->block_sync_cache = 0; sc->drv_stream_detection = 1; /* * Grab the global variables. */ TUNABLE_INT_FETCH("hw.mrsas.debug_level", &sc->mrsas_debug); /* * Grab the global variables. */ TUNABLE_INT_FETCH("hw.mrsas.lb_pending_cmds", &sc->lb_pending_cmds); /* Grab the unit-instance variables */ snprintf(tmpstr, sizeof(tmpstr), "dev.mrsas.%d.debug_level", device_get_unit(sc->mrsas_dev)); TUNABLE_INT_FETCH(tmpstr, &sc->mrsas_debug); } /* * mrsas_alloc_evt_log_info cmd: Allocates memory to get event log information. * Used to get sequence number at driver load time. * input: Adapter soft state * * Allocates DMAable memory for the event log info internal command. */ int mrsas_alloc_evt_log_info_cmd(struct mrsas_softc *sc) { int el_info_size; /* Allocate get event log info command */ el_info_size = sizeof(struct mrsas_evt_log_info); if (bus_dma_tag_create(sc->mrsas_parent_tag, 1, 0, BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL, el_info_size, 1, el_info_size, BUS_DMA_ALLOCNOW, NULL, NULL, &sc->el_info_tag)) { device_printf(sc->mrsas_dev, "Cannot allocate event log info tag\n"); return (ENOMEM); } if (bus_dmamem_alloc(sc->el_info_tag, (void **)&sc->el_info_mem, BUS_DMA_NOWAIT, &sc->el_info_dmamap)) { device_printf(sc->mrsas_dev, "Cannot allocate event log info cmd mem\n"); return (ENOMEM); } if (bus_dmamap_load(sc->el_info_tag, sc->el_info_dmamap, sc->el_info_mem, el_info_size, mrsas_addr_cb, &sc->el_info_phys_addr, BUS_DMA_NOWAIT)) { device_printf(sc->mrsas_dev, "Cannot load event log info cmd mem\n"); return (ENOMEM); } memset(sc->el_info_mem, 0, el_info_size); return (0); } /* * mrsas_free_evt_info_cmd: Free memory for Event log info command * input: Adapter soft state * * Deallocates memory for the event log info internal command. */ void mrsas_free_evt_log_info_cmd(struct mrsas_softc *sc) { if (sc->el_info_phys_addr) bus_dmamap_unload(sc->el_info_tag, sc->el_info_dmamap); if (sc->el_info_mem != NULL) bus_dmamem_free(sc->el_info_tag, sc->el_info_mem, sc->el_info_dmamap); if (sc->el_info_tag != NULL) bus_dma_tag_destroy(sc->el_info_tag); } /* * mrsas_get_seq_num: Get latest event sequence number * @sc: Adapter soft state * @eli: Firmware event log sequence number information. * * Firmware maintains a log of all events in a non-volatile area. * Driver get the sequence number using DCMD * "MR_DCMD_CTRL_EVENT_GET_INFO" at driver load time. */ static int mrsas_get_seq_num(struct mrsas_softc *sc, struct mrsas_evt_log_info *eli) { struct mrsas_mfi_cmd *cmd; struct mrsas_dcmd_frame *dcmd; u_int8_t do_ocr = 1, retcode = 0; cmd = mrsas_get_mfi_cmd(sc); if (!cmd) { device_printf(sc->mrsas_dev, "Failed to get a free cmd\n"); return -ENOMEM; } dcmd = &cmd->frame->dcmd; if (mrsas_alloc_evt_log_info_cmd(sc) != SUCCESS) { device_printf(sc->mrsas_dev, "Cannot allocate evt log info cmd\n"); mrsas_release_mfi_cmd(cmd); return -ENOMEM; } memset(dcmd->mbox.b, 0, MFI_MBOX_SIZE); dcmd->cmd = MFI_CMD_DCMD; dcmd->cmd_status = 0x0; dcmd->sge_count = 1; dcmd->flags = MFI_FRAME_DIR_READ; dcmd->timeout = 0; dcmd->pad_0 = 0; dcmd->data_xfer_len = sizeof(struct mrsas_evt_log_info); dcmd->opcode = MR_DCMD_CTRL_EVENT_GET_INFO; dcmd->sgl.sge32[0].phys_addr = sc->el_info_phys_addr; dcmd->sgl.sge32[0].length = sizeof(struct mrsas_evt_log_info); retcode = mrsas_issue_blocked_cmd(sc, cmd); if (retcode == ETIMEDOUT) goto dcmd_timeout; do_ocr = 0; /* * Copy the data back into callers buffer */ memcpy(eli, sc->el_info_mem, sizeof(struct mrsas_evt_log_info)); mrsas_free_evt_log_info_cmd(sc); dcmd_timeout: if (do_ocr) sc->do_timedout_reset = MFI_DCMD_TIMEOUT_OCR; else mrsas_release_mfi_cmd(cmd); return retcode; } /* * mrsas_register_aen: Register for asynchronous event notification * @sc: Adapter soft state * @seq_num: Starting sequence number * @class_locale: Class of the event * * This function subscribes for events beyond the @seq_num * and type @class_locale. * */ static int mrsas_register_aen(struct mrsas_softc *sc, u_int32_t seq_num, u_int32_t class_locale_word) { int ret_val; struct mrsas_mfi_cmd *cmd; struct mrsas_dcmd_frame *dcmd; union mrsas_evt_class_locale curr_aen; union mrsas_evt_class_locale prev_aen; /* * If there an AEN pending already (aen_cmd), check if the * class_locale of that pending AEN is inclusive of the new AEN * request we currently have. If it is, then we don't have to do * anything. In other words, whichever events the current AEN request * is subscribing to, have already been subscribed to. If the old_cmd * is _not_ inclusive, then we have to abort that command, form a * class_locale that is superset of both old and current and re-issue * to the FW */ curr_aen.word = class_locale_word; if (sc->aen_cmd) { prev_aen.word = sc->aen_cmd->frame->dcmd.mbox.w[1]; /* * A class whose enum value is smaller is inclusive of all * higher values. If a PROGRESS (= -1) was previously * registered, then a new registration requests for higher * classes need not be sent to FW. They are automatically * included. Locale numbers don't have such hierarchy. They * are bitmap values */ if ((prev_aen.members.class <= curr_aen.members.class) && !((prev_aen.members.locale & curr_aen.members.locale) ^ curr_aen.members.locale)) { /* * Previously issued event registration includes * current request. Nothing to do. */ return 0; } else { curr_aen.members.locale |= prev_aen.members.locale; if (prev_aen.members.class < curr_aen.members.class) curr_aen.members.class = prev_aen.members.class; sc->aen_cmd->abort_aen = 1; ret_val = mrsas_issue_blocked_abort_cmd(sc, sc->aen_cmd); if (ret_val) { printf("mrsas: Failed to abort previous AEN command\n"); return ret_val; } else sc->aen_cmd = NULL; } } cmd = mrsas_get_mfi_cmd(sc); if (!cmd) return ENOMEM; dcmd = &cmd->frame->dcmd; memset(sc->evt_detail_mem, 0, sizeof(struct mrsas_evt_detail)); /* * Prepare DCMD for aen registration */ memset(dcmd->mbox.b, 0, MFI_MBOX_SIZE); dcmd->cmd = MFI_CMD_DCMD; dcmd->cmd_status = 0x0; dcmd->sge_count = 1; dcmd->flags = MFI_FRAME_DIR_READ; dcmd->timeout = 0; dcmd->pad_0 = 0; dcmd->data_xfer_len = sizeof(struct mrsas_evt_detail); dcmd->opcode = MR_DCMD_CTRL_EVENT_WAIT; dcmd->mbox.w[0] = seq_num; sc->last_seq_num = seq_num; dcmd->mbox.w[1] = curr_aen.word; dcmd->sgl.sge32[0].phys_addr = (u_int32_t)sc->evt_detail_phys_addr; dcmd->sgl.sge32[0].length = sizeof(struct mrsas_evt_detail); if (sc->aen_cmd != NULL) { mrsas_release_mfi_cmd(cmd); return 0; } /* * Store reference to the cmd used to register for AEN. When an * application wants us to register for AEN, we have to abort this * cmd and re-register with a new EVENT LOCALE supplied by that app */ sc->aen_cmd = cmd; /* * Issue the aen registration frame */ if (mrsas_issue_dcmd(sc, cmd)) { device_printf(sc->mrsas_dev, "Cannot issue AEN DCMD command.\n"); return (1); } return 0; } /* * mrsas_start_aen: Subscribes to AEN during driver load time * @instance: Adapter soft state */ static int mrsas_start_aen(struct mrsas_softc *sc) { struct mrsas_evt_log_info eli; union mrsas_evt_class_locale class_locale; /* Get the latest sequence number from FW */ memset(&eli, 0, sizeof(eli)); if (mrsas_get_seq_num(sc, &eli)) return -1; /* Register AEN with FW for latest sequence number plus 1 */ class_locale.members.reserved = 0; class_locale.members.locale = MR_EVT_LOCALE_ALL; class_locale.members.class = MR_EVT_CLASS_DEBUG; return mrsas_register_aen(sc, eli.newest_seq_num + 1, class_locale.word); } /* * mrsas_setup_msix: Allocate MSI-x vectors * @sc: adapter soft state */ static int mrsas_setup_msix(struct mrsas_softc *sc) { int i; for (i = 0; i < sc->msix_vectors; i++) { sc->irq_context[i].sc = sc; sc->irq_context[i].MSIxIndex = i; sc->irq_id[i] = i + 1; sc->mrsas_irq[i] = bus_alloc_resource_any (sc->mrsas_dev, SYS_RES_IRQ, &sc->irq_id[i] ,RF_ACTIVE); if (sc->mrsas_irq[i] == NULL) { device_printf(sc->mrsas_dev, "Can't allocate MSI-x\n"); goto irq_alloc_failed; } if (bus_setup_intr(sc->mrsas_dev, sc->mrsas_irq[i], INTR_MPSAFE | INTR_TYPE_CAM, NULL, mrsas_isr, &sc->irq_context[i], &sc->intr_handle[i])) { device_printf(sc->mrsas_dev, "Cannot set up MSI-x interrupt handler\n"); goto irq_alloc_failed; } } return SUCCESS; irq_alloc_failed: mrsas_teardown_intr(sc); return (FAIL); } /* * mrsas_allocate_msix: Setup MSI-x vectors * @sc: adapter soft state */ static int mrsas_allocate_msix(struct mrsas_softc *sc) { if (pci_alloc_msix(sc->mrsas_dev, &sc->msix_vectors) == 0) { device_printf(sc->mrsas_dev, "Using MSI-X with %d number" " of vectors\n", sc->msix_vectors); } else { device_printf(sc->mrsas_dev, "MSI-x setup failed\n"); goto irq_alloc_failed; } return SUCCESS; irq_alloc_failed: mrsas_teardown_intr(sc); return (FAIL); } /* * mrsas_attach: PCI entry point * input: pointer to device struct * * Performs setup of PCI and registers, initializes mutexes and linked lists, * registers interrupts and CAM, and initializes the adapter/controller to * its proper state. */ static int mrsas_attach(device_t dev) { struct mrsas_softc *sc = device_get_softc(dev); uint32_t cmd, error; memset(sc, 0, sizeof(struct mrsas_softc)); /* Look up our softc and initialize its fields. */ sc->mrsas_dev = dev; sc->device_id = pci_get_device(dev); switch (sc->device_id) { case MRSAS_INVADER: case MRSAS_FURY: case MRSAS_INTRUDER: case MRSAS_INTRUDER_24: case MRSAS_CUTLASS_52: case MRSAS_CUTLASS_53: sc->mrsas_gen3_ctrl = 1; break; case MRSAS_VENTURA: case MRSAS_CRUSADER: case MRSAS_HARPOON: case MRSAS_TOMCAT: case MRSAS_VENTURA_4PORT: case MRSAS_CRUSADER_4PORT: sc->is_ventura = true; break; case MRSAS_AERO_10E1: case MRSAS_AERO_10E5: device_printf(dev, "Adapter is in configurable secure mode\n"); case MRSAS_AERO_10E2: case MRSAS_AERO_10E6: sc->is_aero = true; break; case MRSAS_AERO_10E0: case MRSAS_AERO_10E3: case MRSAS_AERO_10E4: case MRSAS_AERO_10E7: device_printf(dev, "Adapter is in non-secure mode\n"); return SUCCESS; } mrsas_get_tunables(sc); /* * Set up PCI and registers */ cmd = pci_read_config(dev, PCIR_COMMAND, 2); if ((cmd & PCIM_CMD_PORTEN) == 0) { return (ENXIO); } /* Force the busmaster enable bit on. */ cmd |= PCIM_CMD_BUSMASTEREN; pci_write_config(dev, PCIR_COMMAND, cmd, 2); /* For Ventura/Aero system registers are mapped to BAR0 */ if (sc->is_ventura || sc->is_aero) sc->reg_res_id = PCIR_BAR(0); /* BAR0 offset */ else sc->reg_res_id = PCIR_BAR(1); /* BAR1 offset */ if ((sc->reg_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &(sc->reg_res_id), RF_ACTIVE)) == NULL) { device_printf(dev, "Cannot allocate PCI registers\n"); goto attach_fail; } sc->bus_tag = rman_get_bustag(sc->reg_res); sc->bus_handle = rman_get_bushandle(sc->reg_res); /* Intialize mutexes */ mtx_init(&sc->sim_lock, "mrsas_sim_lock", NULL, MTX_DEF); mtx_init(&sc->pci_lock, "mrsas_pci_lock", NULL, MTX_DEF); mtx_init(&sc->io_lock, "mrsas_io_lock", NULL, MTX_DEF); mtx_init(&sc->aen_lock, "mrsas_aen_lock", NULL, MTX_DEF); mtx_init(&sc->ioctl_lock, "mrsas_ioctl_lock", NULL, MTX_SPIN); mtx_init(&sc->mpt_cmd_pool_lock, "mrsas_mpt_cmd_pool_lock", NULL, MTX_DEF); mtx_init(&sc->mfi_cmd_pool_lock, "mrsas_mfi_cmd_pool_lock", NULL, MTX_DEF); mtx_init(&sc->raidmap_lock, "mrsas_raidmap_lock", NULL, MTX_DEF); mtx_init(&sc->stream_lock, "mrsas_stream_lock", NULL, MTX_DEF); /* Intialize linked list */ TAILQ_INIT(&sc->mrsas_mpt_cmd_list_head); TAILQ_INIT(&sc->mrsas_mfi_cmd_list_head); mrsas_atomic_set(&sc->fw_outstanding, 0); mrsas_atomic_set(&sc->target_reset_outstanding, 0); mrsas_atomic_set(&sc->prp_count, 0); mrsas_atomic_set(&sc->sge_holes, 0); sc->io_cmds_highwater = 0; sc->adprecovery = MRSAS_HBA_OPERATIONAL; sc->UnevenSpanSupport = 0; sc->msix_enable = 0; /* Initialize Firmware */ if (mrsas_init_fw(sc) != SUCCESS) { goto attach_fail_fw; } /* Register mrsas to CAM layer */ if ((mrsas_cam_attach(sc) != SUCCESS)) { goto attach_fail_cam; } /* Register IRQs */ if (mrsas_setup_irq(sc) != SUCCESS) { goto attach_fail_irq; } error = mrsas_kproc_create(mrsas_ocr_thread, sc, &sc->ocr_thread, 0, 0, "mrsas_ocr%d", device_get_unit(sc->mrsas_dev)); if (error) { device_printf(sc->mrsas_dev, "Error %d starting OCR thread\n", error); goto attach_fail_ocr_thread; } /* * After FW initialization and OCR thread creation * we will defer the cdev creation, AEN setup on ICH callback */ sc->mrsas_ich.ich_func = mrsas_ich_startup; sc->mrsas_ich.ich_arg = sc; if (config_intrhook_establish(&sc->mrsas_ich) != 0) { device_printf(sc->mrsas_dev, "Config hook is already established\n"); } mrsas_setup_sysctl(sc); return SUCCESS; attach_fail_ocr_thread: if (sc->ocr_thread_active) wakeup(&sc->ocr_chan); attach_fail_irq: mrsas_teardown_intr(sc); attach_fail_cam: mrsas_cam_detach(sc); attach_fail_fw: /* if MSIX vector is allocated and FW Init FAILED then release MSIX */ if (sc->msix_enable == 1) pci_release_msi(sc->mrsas_dev); mrsas_free_mem(sc); mtx_destroy(&sc->sim_lock); mtx_destroy(&sc->aen_lock); mtx_destroy(&sc->pci_lock); mtx_destroy(&sc->io_lock); mtx_destroy(&sc->ioctl_lock); mtx_destroy(&sc->mpt_cmd_pool_lock); mtx_destroy(&sc->mfi_cmd_pool_lock); mtx_destroy(&sc->raidmap_lock); mtx_destroy(&sc->stream_lock); attach_fail: if (sc->reg_res) { bus_release_resource(sc->mrsas_dev, SYS_RES_MEMORY, sc->reg_res_id, sc->reg_res); } return (ENXIO); } /* * Interrupt config hook */ static void mrsas_ich_startup(void *arg) { int i = 0; struct mrsas_softc *sc = (struct mrsas_softc *)arg; /* * Intialize a counting Semaphore to take care no. of concurrent IOCTLs */ sema_init(&sc->ioctl_count_sema, MRSAS_MAX_IOCTL_CMDS, IOCTL_SEMA_DESCRIPTION); /* Create a /dev entry for mrsas controller. */ sc->mrsas_cdev = make_dev(&mrsas_cdevsw, device_get_unit(sc->mrsas_dev), UID_ROOT, GID_OPERATOR, (S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP), "mrsas%u", device_get_unit(sc->mrsas_dev)); if (device_get_unit(sc->mrsas_dev) == 0) { make_dev_alias_p(MAKEDEV_CHECKNAME, &sc->mrsas_linux_emulator_cdev, sc->mrsas_cdev, "megaraid_sas_ioctl_node"); } if (sc->mrsas_cdev) sc->mrsas_cdev->si_drv1 = sc; /* * Add this controller to mrsas_mgmt_info structure so that it can be * exported to management applications */ if (device_get_unit(sc->mrsas_dev) == 0) memset(&mrsas_mgmt_info, 0, sizeof(mrsas_mgmt_info)); mrsas_mgmt_info.count++; mrsas_mgmt_info.sc_ptr[mrsas_mgmt_info.max_index] = sc; mrsas_mgmt_info.max_index++; /* Enable Interrupts */ mrsas_enable_intr(sc); /* Call DCMD get_pd_info for all system PDs */ for (i = 0; i < MRSAS_MAX_PD; i++) { if ((sc->target_list[i].target_id != 0xffff) && sc->pd_info_mem) mrsas_get_pd_info(sc, sc->target_list[i].target_id); } /* Initiate AEN (Asynchronous Event Notification) */ if (mrsas_start_aen(sc)) { device_printf(sc->mrsas_dev, "Error: AEN registration FAILED !!! " "Further events from the controller will not be communicated.\n" "Either there is some problem in the controller" "or the controller does not support AEN.\n" "Please contact to the SUPPORT TEAM if the problem persists\n"); } if (sc->mrsas_ich.ich_arg != NULL) { device_printf(sc->mrsas_dev, "Disestablish mrsas intr hook\n"); config_intrhook_disestablish(&sc->mrsas_ich); sc->mrsas_ich.ich_arg = NULL; } } /* * mrsas_detach: De-allocates and teardown resources * input: pointer to device struct * * This function is the entry point for device disconnect and detach. * It performs memory de-allocations, shutdown of the controller and various * teardown and destroy resource functions. */ static int mrsas_detach(device_t dev) { struct mrsas_softc *sc; int i = 0; sc = device_get_softc(dev); sc->remove_in_progress = 1; /* Destroy the character device so no other IOCTL will be handled */ if ((device_get_unit(dev) == 0) && sc->mrsas_linux_emulator_cdev) destroy_dev(sc->mrsas_linux_emulator_cdev); destroy_dev(sc->mrsas_cdev); /* * Take the instance off the instance array. Note that we will not * decrement the max_index. We let this array be sparse array */ for (i = 0; i < mrsas_mgmt_info.max_index; i++) { if (mrsas_mgmt_info.sc_ptr[i] == sc) { mrsas_mgmt_info.count--; mrsas_mgmt_info.sc_ptr[i] = NULL; break; } } if (sc->ocr_thread_active) wakeup(&sc->ocr_chan); while (sc->reset_in_progress) { i++; if (!(i % MRSAS_RESET_NOTICE_INTERVAL)) { mrsas_dprint(sc, MRSAS_INFO, "[%2d]waiting for OCR to be finished from %s\n", i, __func__); } pause("mr_shutdown", hz); } i = 0; while (sc->ocr_thread_active) { i++; if (!(i % MRSAS_RESET_NOTICE_INTERVAL)) { mrsas_dprint(sc, MRSAS_INFO, "[%2d]waiting for " "mrsas_ocr thread to quit ocr %d\n", i, sc->ocr_thread_active); } pause("mr_shutdown", hz); } mrsas_flush_cache(sc); mrsas_shutdown_ctlr(sc, MR_DCMD_CTRL_SHUTDOWN); mrsas_disable_intr(sc); if ((sc->is_ventura || sc->is_aero) && sc->streamDetectByLD) { for (i = 0; i < MAX_LOGICAL_DRIVES_EXT; ++i) free(sc->streamDetectByLD[i], M_MRSAS); free(sc->streamDetectByLD, M_MRSAS); sc->streamDetectByLD = NULL; } mrsas_cam_detach(sc); mrsas_teardown_intr(sc); mrsas_free_mem(sc); mtx_destroy(&sc->sim_lock); mtx_destroy(&sc->aen_lock); mtx_destroy(&sc->pci_lock); mtx_destroy(&sc->io_lock); mtx_destroy(&sc->ioctl_lock); mtx_destroy(&sc->mpt_cmd_pool_lock); mtx_destroy(&sc->mfi_cmd_pool_lock); mtx_destroy(&sc->raidmap_lock); mtx_destroy(&sc->stream_lock); /* Wait for all the semaphores to be released */ while (sema_value(&sc->ioctl_count_sema) != MRSAS_MAX_IOCTL_CMDS) pause("mr_shutdown", hz); /* Destroy the counting semaphore created for Ioctl */ sema_destroy(&sc->ioctl_count_sema); if (sc->reg_res) { bus_release_resource(sc->mrsas_dev, SYS_RES_MEMORY, sc->reg_res_id, sc->reg_res); } if (sc->sysctl_tree != NULL) sysctl_ctx_free(&sc->sysctl_ctx); return (0); } +static int +mrsas_shutdown(device_t dev) +{ + struct mrsas_softc *sc; + int i; + + sc = device_get_softc(dev); + sc->remove_in_progress = 1; + if (panicstr == NULL) { + if (sc->ocr_thread_active) + wakeup(&sc->ocr_chan); + i = 0; + while (sc->reset_in_progress && i < 15) { + i++; + if ((i % MRSAS_RESET_NOTICE_INTERVAL) == 0) { + mrsas_dprint(sc, MRSAS_INFO, + "[%2d]waiting for OCR to be finished " + "from %s\n", i, __func__); + } + pause("mr_shutdown", hz); + } + if (sc->reset_in_progress) { + mrsas_dprint(sc, MRSAS_INFO, + "gave up waiting for OCR to be finished\n"); + } + } + + mrsas_flush_cache(sc); + mrsas_shutdown_ctlr(sc, MR_DCMD_CTRL_SHUTDOWN); + mrsas_disable_intr(sc); + return (0); +} + /* * mrsas_free_mem: Frees allocated memory * input: Adapter instance soft state * * This function is called from mrsas_detach() to free previously allocated * memory. */ void mrsas_free_mem(struct mrsas_softc *sc) { int i; u_int32_t max_fw_cmds; struct mrsas_mfi_cmd *mfi_cmd; struct mrsas_mpt_cmd *mpt_cmd; /* * Free RAID map memory */ for (i = 0; i < 2; i++) { if (sc->raidmap_phys_addr[i]) bus_dmamap_unload(sc->raidmap_tag[i], sc->raidmap_dmamap[i]); if (sc->raidmap_mem[i] != NULL) bus_dmamem_free(sc->raidmap_tag[i], sc->raidmap_mem[i], sc->raidmap_dmamap[i]); if (sc->raidmap_tag[i] != NULL) bus_dma_tag_destroy(sc->raidmap_tag[i]); if (sc->ld_drv_map[i] != NULL) free(sc->ld_drv_map[i], M_MRSAS); } for (i = 0; i < 2; i++) { if (sc->jbodmap_phys_addr[i]) bus_dmamap_unload(sc->jbodmap_tag[i], sc->jbodmap_dmamap[i]); if (sc->jbodmap_mem[i] != NULL) bus_dmamem_free(sc->jbodmap_tag[i], sc->jbodmap_mem[i], sc->jbodmap_dmamap[i]); if (sc->jbodmap_tag[i] != NULL) bus_dma_tag_destroy(sc->jbodmap_tag[i]); } /* * Free version buffer memory */ if (sc->verbuf_phys_addr) bus_dmamap_unload(sc->verbuf_tag, sc->verbuf_dmamap); if (sc->verbuf_mem != NULL) bus_dmamem_free(sc->verbuf_tag, sc->verbuf_mem, sc->verbuf_dmamap); if (sc->verbuf_tag != NULL) bus_dma_tag_destroy(sc->verbuf_tag); /* * Free sense buffer memory */ if (sc->sense_phys_addr) bus_dmamap_unload(sc->sense_tag, sc->sense_dmamap); if (sc->sense_mem != NULL) bus_dmamem_free(sc->sense_tag, sc->sense_mem, sc->sense_dmamap); if (sc->sense_tag != NULL) bus_dma_tag_destroy(sc->sense_tag); /* * Free chain frame memory */ if (sc->chain_frame_phys_addr) bus_dmamap_unload(sc->chain_frame_tag, sc->chain_frame_dmamap); if (sc->chain_frame_mem != NULL) bus_dmamem_free(sc->chain_frame_tag, sc->chain_frame_mem, sc->chain_frame_dmamap); if (sc->chain_frame_tag != NULL) bus_dma_tag_destroy(sc->chain_frame_tag); /* * Free IO Request memory */ if (sc->io_request_phys_addr) bus_dmamap_unload(sc->io_request_tag, sc->io_request_dmamap); if (sc->io_request_mem != NULL) bus_dmamem_free(sc->io_request_tag, sc->io_request_mem, sc->io_request_dmamap); if (sc->io_request_tag != NULL) bus_dma_tag_destroy(sc->io_request_tag); /* * Free Reply Descriptor memory */ if (sc->reply_desc_phys_addr) bus_dmamap_unload(sc->reply_desc_tag, sc->reply_desc_dmamap); if (sc->reply_desc_mem != NULL) bus_dmamem_free(sc->reply_desc_tag, sc->reply_desc_mem, sc->reply_desc_dmamap); if (sc->reply_desc_tag != NULL) bus_dma_tag_destroy(sc->reply_desc_tag); /* * Free event detail memory */ if (sc->evt_detail_phys_addr) bus_dmamap_unload(sc->evt_detail_tag, sc->evt_detail_dmamap); if (sc->evt_detail_mem != NULL) bus_dmamem_free(sc->evt_detail_tag, sc->evt_detail_mem, sc->evt_detail_dmamap); if (sc->evt_detail_tag != NULL) bus_dma_tag_destroy(sc->evt_detail_tag); /* * Free PD info memory */ if (sc->pd_info_phys_addr) bus_dmamap_unload(sc->pd_info_tag, sc->pd_info_dmamap); if (sc->pd_info_mem != NULL) bus_dmamem_free(sc->pd_info_tag, sc->pd_info_mem, sc->pd_info_dmamap); if (sc->pd_info_tag != NULL) bus_dma_tag_destroy(sc->pd_info_tag); /* * Free MFI frames */ if (sc->mfi_cmd_list) { for (i = 0; i < MRSAS_MAX_MFI_CMDS; i++) { mfi_cmd = sc->mfi_cmd_list[i]; mrsas_free_frame(sc, mfi_cmd); } } if (sc->mficmd_frame_tag != NULL) bus_dma_tag_destroy(sc->mficmd_frame_tag); /* * Free MPT internal command list */ max_fw_cmds = sc->max_fw_cmds; if (sc->mpt_cmd_list) { for (i = 0; i < max_fw_cmds; i++) { mpt_cmd = sc->mpt_cmd_list[i]; bus_dmamap_destroy(sc->data_tag, mpt_cmd->data_dmamap); free(sc->mpt_cmd_list[i], M_MRSAS); } free(sc->mpt_cmd_list, M_MRSAS); sc->mpt_cmd_list = NULL; } /* * Free MFI internal command list */ if (sc->mfi_cmd_list) { for (i = 0; i < MRSAS_MAX_MFI_CMDS; i++) { free(sc->mfi_cmd_list[i], M_MRSAS); } free(sc->mfi_cmd_list, M_MRSAS); sc->mfi_cmd_list = NULL; } /* * Free request descriptor memory */ free(sc->req_desc, M_MRSAS); sc->req_desc = NULL; /* * Destroy parent tag */ if (sc->mrsas_parent_tag != NULL) bus_dma_tag_destroy(sc->mrsas_parent_tag); /* * Free ctrl_info memory */ if (sc->ctrl_info != NULL) free(sc->ctrl_info, M_MRSAS); } /* * mrsas_teardown_intr: Teardown interrupt * input: Adapter instance soft state * * This function is called from mrsas_detach() to teardown and release bus * interrupt resourse. */ void mrsas_teardown_intr(struct mrsas_softc *sc) { int i; if (!sc->msix_enable) { if (sc->intr_handle[0]) bus_teardown_intr(sc->mrsas_dev, sc->mrsas_irq[0], sc->intr_handle[0]); if (sc->mrsas_irq[0] != NULL) bus_release_resource(sc->mrsas_dev, SYS_RES_IRQ, sc->irq_id[0], sc->mrsas_irq[0]); sc->intr_handle[0] = NULL; } else { for (i = 0; i < sc->msix_vectors; i++) { if (sc->intr_handle[i]) bus_teardown_intr(sc->mrsas_dev, sc->mrsas_irq[i], sc->intr_handle[i]); if (sc->mrsas_irq[i] != NULL) bus_release_resource(sc->mrsas_dev, SYS_RES_IRQ, sc->irq_id[i], sc->mrsas_irq[i]); sc->intr_handle[i] = NULL; } pci_release_msi(sc->mrsas_dev); } } /* * mrsas_suspend: Suspend entry point * input: Device struct pointer * * This function is the entry point for system suspend from the OS. */ static int mrsas_suspend(device_t dev) { /* This will be filled when the driver will have hibernation support */ return (0); } /* * mrsas_resume: Resume entry point * input: Device struct pointer * * This function is the entry point for system resume from the OS. */ static int mrsas_resume(device_t dev) { /* This will be filled when the driver will have hibernation support */ return (0); } /** * mrsas_get_softc_instance: Find softc instance based on cmd type * * This function will return softc instance based on cmd type. * In some case, application fire ioctl on required management instance and * do not provide host_no. Use cdev->si_drv1 to get softc instance for those * case, else get the softc instance from host_no provided by application in * user data. */ static struct mrsas_softc * mrsas_get_softc_instance(struct cdev *dev, u_long cmd, caddr_t arg) { struct mrsas_softc *sc = NULL; struct mrsas_iocpacket *user_ioc = (struct mrsas_iocpacket *)arg; if (cmd == MRSAS_IOC_GET_PCI_INFO) { sc = dev->si_drv1; } else { /* * get the Host number & the softc from data sent by the * Application */ sc = mrsas_mgmt_info.sc_ptr[user_ioc->host_no]; if (sc == NULL) printf("There is no Controller number %d\n", user_ioc->host_no); else if (user_ioc->host_no >= mrsas_mgmt_info.max_index) mrsas_dprint(sc, MRSAS_FAULT, "Invalid Controller number %d\n", user_ioc->host_no); } return sc; } /* * mrsas_ioctl: IOCtl commands entry point. * * This function is the entry point for IOCtls from the OS. It calls the * appropriate function for processing depending on the command received. */ static int mrsas_ioctl(struct cdev *dev, u_long cmd, caddr_t arg, int flag, struct thread *td) { struct mrsas_softc *sc; int ret = 0, i = 0; MRSAS_DRV_PCI_INFORMATION *pciDrvInfo; sc = mrsas_get_softc_instance(dev, cmd, arg); if (!sc) return ENOENT; if (sc->remove_in_progress || (sc->adprecovery == MRSAS_HW_CRITICAL_ERROR)) { mrsas_dprint(sc, MRSAS_INFO, "Either driver remove or shutdown called or " "HW is in unrecoverable critical error state.\n"); return ENOENT; } mtx_lock_spin(&sc->ioctl_lock); if (!sc->reset_in_progress) { mtx_unlock_spin(&sc->ioctl_lock); goto do_ioctl; } mtx_unlock_spin(&sc->ioctl_lock); while (sc->reset_in_progress) { i++; if (!(i % MRSAS_RESET_NOTICE_INTERVAL)) { mrsas_dprint(sc, MRSAS_INFO, "[%2d]waiting for OCR to be finished from %s\n", i, __func__); } pause("mr_ioctl", hz); } do_ioctl: switch (cmd) { case MRSAS_IOC_FIRMWARE_PASS_THROUGH64: #ifdef COMPAT_FREEBSD32 case MRSAS_IOC_FIRMWARE_PASS_THROUGH32: #endif /* * Decrement the Ioctl counting Semaphore before getting an * mfi command */ sema_wait(&sc->ioctl_count_sema); ret = mrsas_passthru(sc, (void *)arg, cmd); /* Increment the Ioctl counting semaphore value */ sema_post(&sc->ioctl_count_sema); break; case MRSAS_IOC_SCAN_BUS: ret = mrsas_bus_scan(sc); break; case MRSAS_IOC_GET_PCI_INFO: pciDrvInfo = (MRSAS_DRV_PCI_INFORMATION *) arg; memset(pciDrvInfo, 0, sizeof(MRSAS_DRV_PCI_INFORMATION)); pciDrvInfo->busNumber = pci_get_bus(sc->mrsas_dev); pciDrvInfo->deviceNumber = pci_get_slot(sc->mrsas_dev); pciDrvInfo->functionNumber = pci_get_function(sc->mrsas_dev); pciDrvInfo->domainID = pci_get_domain(sc->mrsas_dev); mrsas_dprint(sc, MRSAS_INFO, "pci bus no: %d," "pci device no: %d, pci function no: %d," "pci domain ID: %d\n", pciDrvInfo->busNumber, pciDrvInfo->deviceNumber, pciDrvInfo->functionNumber, pciDrvInfo->domainID); ret = 0; break; default: mrsas_dprint(sc, MRSAS_TRACE, "IOCTL command 0x%lx is not handled\n", cmd); ret = ENOENT; } return (ret); } /* * mrsas_poll: poll entry point for mrsas driver fd * * This function is the entry point for poll from the OS. It waits for some AEN * events to be triggered from the controller and notifies back. */ static int mrsas_poll(struct cdev *dev, int poll_events, struct thread *td) { struct mrsas_softc *sc; int revents = 0; sc = dev->si_drv1; if (poll_events & (POLLIN | POLLRDNORM)) { if (sc->mrsas_aen_triggered) { revents |= poll_events & (POLLIN | POLLRDNORM); } } if (revents == 0) { if (poll_events & (POLLIN | POLLRDNORM)) { mtx_lock(&sc->aen_lock); sc->mrsas_poll_waiting = 1; selrecord(td, &sc->mrsas_select); mtx_unlock(&sc->aen_lock); } } return revents; } /* * mrsas_setup_irq: Set up interrupt * input: Adapter instance soft state * * This function sets up interrupts as a bus resource, with flags indicating * resource permitting contemporaneous sharing and for resource to activate * atomically. */ static int mrsas_setup_irq(struct mrsas_softc *sc) { if (sc->msix_enable && (mrsas_setup_msix(sc) == SUCCESS)) device_printf(sc->mrsas_dev, "MSI-x interrupts setup success\n"); else { device_printf(sc->mrsas_dev, "Fall back to legacy interrupt\n"); sc->irq_context[0].sc = sc; sc->irq_context[0].MSIxIndex = 0; sc->irq_id[0] = 0; sc->mrsas_irq[0] = bus_alloc_resource_any(sc->mrsas_dev, SYS_RES_IRQ, &sc->irq_id[0], RF_SHAREABLE | RF_ACTIVE); if (sc->mrsas_irq[0] == NULL) { device_printf(sc->mrsas_dev, "Cannot allocate legcay" "interrupt\n"); return (FAIL); } if (bus_setup_intr(sc->mrsas_dev, sc->mrsas_irq[0], INTR_MPSAFE | INTR_TYPE_CAM, NULL, mrsas_isr, &sc->irq_context[0], &sc->intr_handle[0])) { device_printf(sc->mrsas_dev, "Cannot set up legacy" "interrupt\n"); return (FAIL); } } return (0); } /* * mrsas_isr: ISR entry point * input: argument pointer * * This function is the interrupt service routine entry point. There are two * types of interrupts, state change interrupt and response interrupt. If an * interrupt is not ours, we just return. */ void mrsas_isr(void *arg) { struct mrsas_irq_context *irq_context = (struct mrsas_irq_context *)arg; struct mrsas_softc *sc = irq_context->sc; int status = 0; if (sc->mask_interrupts) return; if (!sc->msix_vectors) { status = mrsas_clear_intr(sc); if (!status) return; } /* If we are resetting, bail */ if (mrsas_test_bit(MRSAS_FUSION_IN_RESET, &sc->reset_flags)) { printf(" Entered into ISR when OCR is going active. \n"); mrsas_clear_intr(sc); return; } /* Process for reply request and clear response interrupt */ if (mrsas_complete_cmd(sc, irq_context->MSIxIndex) != SUCCESS) mrsas_clear_intr(sc); return; } /* * mrsas_complete_cmd: Process reply request * input: Adapter instance soft state * * This function is called from mrsas_isr() to process reply request and clear * response interrupt. Processing of the reply request entails walking * through the reply descriptor array for the command request pended from * Firmware. We look at the Function field to determine the command type and * perform the appropriate action. Before we return, we clear the response * interrupt. */ int mrsas_complete_cmd(struct mrsas_softc *sc, u_int32_t MSIxIndex) { Mpi2ReplyDescriptorsUnion_t *desc; MPI2_SCSI_IO_SUCCESS_REPLY_DESCRIPTOR *reply_desc; MRSAS_RAID_SCSI_IO_REQUEST *scsi_io_req; struct mrsas_mpt_cmd *cmd_mpt, *r1_cmd = NULL; struct mrsas_mfi_cmd *cmd_mfi; u_int8_t reply_descript_type, *sense; u_int16_t smid, num_completed; u_int8_t status, extStatus; union desc_value desc_val; PLD_LOAD_BALANCE_INFO lbinfo; u_int32_t device_id, data_length; int threshold_reply_count = 0; #if TM_DEBUG MR_TASK_MANAGE_REQUEST *mr_tm_req; MPI2_SCSI_TASK_MANAGE_REQUEST *mpi_tm_req; #endif /* If we have a hardware error, not need to continue */ if (sc->adprecovery == MRSAS_HW_CRITICAL_ERROR) return (DONE); desc = sc->reply_desc_mem; desc += ((MSIxIndex * sc->reply_alloc_sz) / sizeof(MPI2_REPLY_DESCRIPTORS_UNION)) + sc->last_reply_idx[MSIxIndex]; reply_desc = (MPI2_SCSI_IO_SUCCESS_REPLY_DESCRIPTOR *) desc; desc_val.word = desc->Words; num_completed = 0; reply_descript_type = reply_desc->ReplyFlags & MPI2_RPY_DESCRIPT_FLAGS_TYPE_MASK; /* Find our reply descriptor for the command and process */ while ((desc_val.u.low != 0xFFFFFFFF) && (desc_val.u.high != 0xFFFFFFFF)) { smid = reply_desc->SMID; cmd_mpt = sc->mpt_cmd_list[smid - 1]; scsi_io_req = (MRSAS_RAID_SCSI_IO_REQUEST *) cmd_mpt->io_request; status = scsi_io_req->RaidContext.raid_context.status; extStatus = scsi_io_req->RaidContext.raid_context.exStatus; sense = cmd_mpt->sense; data_length = scsi_io_req->DataLength; switch (scsi_io_req->Function) { case MPI2_FUNCTION_SCSI_TASK_MGMT: #if TM_DEBUG mr_tm_req = (MR_TASK_MANAGE_REQUEST *) cmd_mpt->io_request; mpi_tm_req = (MPI2_SCSI_TASK_MANAGE_REQUEST *) &mr_tm_req->TmRequest; device_printf(sc->mrsas_dev, "TM completion type 0x%X, " "TaskMID: 0x%X", mpi_tm_req->TaskType, mpi_tm_req->TaskMID); #endif wakeup_one((void *)&sc->ocr_chan); break; case MPI2_FUNCTION_SCSI_IO_REQUEST: /* Fast Path IO. */ device_id = cmd_mpt->ccb_ptr->ccb_h.target_id; lbinfo = &sc->load_balance_info[device_id]; /* R1 load balancing for READ */ if (cmd_mpt->load_balance == MRSAS_LOAD_BALANCE_FLAG) { mrsas_atomic_dec(&lbinfo->scsi_pending_cmds[cmd_mpt->pd_r1_lb]); cmd_mpt->load_balance &= ~MRSAS_LOAD_BALANCE_FLAG; } /* Fall thru and complete IO */ case MRSAS_MPI2_FUNCTION_LD_IO_REQUEST: if (cmd_mpt->r1_alt_dev_handle == MR_DEVHANDLE_INVALID) { mrsas_map_mpt_cmd_status(cmd_mpt, cmd_mpt->ccb_ptr, status, extStatus, data_length, sense); mrsas_cmd_done(sc, cmd_mpt); mrsas_atomic_dec(&sc->fw_outstanding); } else { /* * If the peer Raid 1/10 fast path failed, * mark IO as failed to the scsi layer. * Overwrite the current status by the failed status * and make sure that if any command fails, * driver returns fail status to CAM. */ cmd_mpt->cmd_completed = 1; r1_cmd = cmd_mpt->peer_cmd; if (r1_cmd->cmd_completed) { if (r1_cmd->io_request->RaidContext.raid_context.status != MFI_STAT_OK) { status = r1_cmd->io_request->RaidContext.raid_context.status; extStatus = r1_cmd->io_request->RaidContext.raid_context.exStatus; data_length = r1_cmd->io_request->DataLength; sense = r1_cmd->sense; } r1_cmd->ccb_ptr = NULL; if (r1_cmd->callout_owner) { callout_stop(&r1_cmd->cm_callout); r1_cmd->callout_owner = false; } mrsas_release_mpt_cmd(r1_cmd); mrsas_atomic_dec(&sc->fw_outstanding); mrsas_map_mpt_cmd_status(cmd_mpt, cmd_mpt->ccb_ptr, status, extStatus, data_length, sense); mrsas_cmd_done(sc, cmd_mpt); mrsas_atomic_dec(&sc->fw_outstanding); } } break; case MRSAS_MPI2_FUNCTION_PASSTHRU_IO_REQUEST: /* MFI command */ cmd_mfi = sc->mfi_cmd_list[cmd_mpt->sync_cmd_idx]; /* * Make sure NOT TO release the mfi command from the called * function's context if it is fired with issue_polled call. * And also make sure that the issue_polled call should only be * used if INTERRUPT IS DISABLED. */ if (cmd_mfi->frame->hdr.flags & MFI_FRAME_DONT_POST_IN_REPLY_QUEUE) mrsas_release_mfi_cmd(cmd_mfi); else mrsas_complete_mptmfi_passthru(sc, cmd_mfi, status); break; } sc->last_reply_idx[MSIxIndex]++; if (sc->last_reply_idx[MSIxIndex] >= sc->reply_q_depth) sc->last_reply_idx[MSIxIndex] = 0; desc->Words = ~((uint64_t)0x00); /* set it back to all * 0xFFFFFFFFs */ num_completed++; threshold_reply_count++; /* Get the next reply descriptor */ if (!sc->last_reply_idx[MSIxIndex]) { desc = sc->reply_desc_mem; desc += ((MSIxIndex * sc->reply_alloc_sz) / sizeof(MPI2_REPLY_DESCRIPTORS_UNION)); } else desc++; reply_desc = (MPI2_SCSI_IO_SUCCESS_REPLY_DESCRIPTOR *) desc; desc_val.word = desc->Words; reply_descript_type = reply_desc->ReplyFlags & MPI2_RPY_DESCRIPT_FLAGS_TYPE_MASK; if (reply_descript_type == MPI2_RPY_DESCRIPT_FLAGS_UNUSED) break; /* * Write to reply post index after completing threshold reply * count and still there are more replies in reply queue * pending to be completed. */ if (threshold_reply_count >= THRESHOLD_REPLY_COUNT) { if (sc->msix_enable) { if (sc->msix_combined) mrsas_write_reg(sc, sc->msix_reg_offset[MSIxIndex / 8], ((MSIxIndex & 0x7) << 24) | sc->last_reply_idx[MSIxIndex]); else mrsas_write_reg(sc, sc->msix_reg_offset[0], (MSIxIndex << 24) | sc->last_reply_idx[MSIxIndex]); } else mrsas_write_reg(sc, offsetof(mrsas_reg_set, reply_post_host_index), sc->last_reply_idx[0]); threshold_reply_count = 0; } } /* No match, just return */ if (num_completed == 0) return (DONE); /* Clear response interrupt */ if (sc->msix_enable) { if (sc->msix_combined) { mrsas_write_reg(sc, sc->msix_reg_offset[MSIxIndex / 8], ((MSIxIndex & 0x7) << 24) | sc->last_reply_idx[MSIxIndex]); } else mrsas_write_reg(sc, sc->msix_reg_offset[0], (MSIxIndex << 24) | sc->last_reply_idx[MSIxIndex]); } else mrsas_write_reg(sc, offsetof(mrsas_reg_set, reply_post_host_index), sc->last_reply_idx[0]); return (0); } /* * mrsas_map_mpt_cmd_status: Allocate DMAable memory. * input: Adapter instance soft state * * This function is called from mrsas_complete_cmd(), for LD IO and FastPath IO. * It checks the command status and maps the appropriate CAM status for the * CCB. */ void mrsas_map_mpt_cmd_status(struct mrsas_mpt_cmd *cmd, union ccb *ccb_ptr, u_int8_t status, u_int8_t extStatus, u_int32_t data_length, u_int8_t *sense) { struct mrsas_softc *sc = cmd->sc; u_int8_t *sense_data; switch (status) { case MFI_STAT_OK: ccb_ptr->ccb_h.status = CAM_REQ_CMP; break; case MFI_STAT_SCSI_IO_FAILED: case MFI_STAT_SCSI_DONE_WITH_ERROR: ccb_ptr->ccb_h.status = CAM_SCSI_STATUS_ERROR; sense_data = (u_int8_t *)&ccb_ptr->csio.sense_data; if (sense_data) { /* For now just copy 18 bytes back */ memcpy(sense_data, sense, 18); ccb_ptr->csio.sense_len = 18; ccb_ptr->ccb_h.status |= CAM_AUTOSNS_VALID; } break; case MFI_STAT_LD_OFFLINE: case MFI_STAT_DEVICE_NOT_FOUND: if (ccb_ptr->ccb_h.target_lun) ccb_ptr->ccb_h.status |= CAM_LUN_INVALID; else ccb_ptr->ccb_h.status |= CAM_DEV_NOT_THERE; break; case MFI_STAT_CONFIG_SEQ_MISMATCH: ccb_ptr->ccb_h.status |= CAM_REQUEUE_REQ; break; default: device_printf(sc->mrsas_dev, "FW cmd complete status %x\n", status); ccb_ptr->ccb_h.status = CAM_REQ_CMP_ERR; ccb_ptr->csio.scsi_status = status; } return; } /* * mrsas_alloc_mem: Allocate DMAable memory * input: Adapter instance soft state * * This function creates the parent DMA tag and allocates DMAable memory. DMA * tag describes constraints of DMA mapping. Memory allocated is mapped into * Kernel virtual address. Callback argument is physical memory address. */ static int mrsas_alloc_mem(struct mrsas_softc *sc) { u_int32_t verbuf_size, io_req_size, reply_desc_size, sense_size, chain_frame_size, evt_detail_size, count, pd_info_size; /* * Allocate parent DMA tag */ if (bus_dma_tag_create(NULL, /* parent */ 1, /* alignment */ 0, /* boundary */ BUS_SPACE_MAXADDR, /* lowaddr */ BUS_SPACE_MAXADDR, /* highaddr */ NULL, NULL, /* filter, filterarg */ MAXPHYS, /* maxsize */ sc->max_num_sge, /* nsegments */ MAXPHYS, /* maxsegsize */ 0, /* flags */ NULL, NULL, /* lockfunc, lockarg */ &sc->mrsas_parent_tag /* tag */ )) { device_printf(sc->mrsas_dev, "Cannot allocate parent DMA tag\n"); return (ENOMEM); } /* * Allocate for version buffer */ verbuf_size = MRSAS_MAX_NAME_LENGTH * (sizeof(bus_addr_t)); if (bus_dma_tag_create(sc->mrsas_parent_tag, 1, 0, BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL, verbuf_size, 1, verbuf_size, BUS_DMA_ALLOCNOW, NULL, NULL, &sc->verbuf_tag)) { device_printf(sc->mrsas_dev, "Cannot allocate verbuf DMA tag\n"); return (ENOMEM); } if (bus_dmamem_alloc(sc->verbuf_tag, (void **)&sc->verbuf_mem, BUS_DMA_NOWAIT, &sc->verbuf_dmamap)) { device_printf(sc->mrsas_dev, "Cannot allocate verbuf memory\n"); return (ENOMEM); } bzero(sc->verbuf_mem, verbuf_size); if (bus_dmamap_load(sc->verbuf_tag, sc->verbuf_dmamap, sc->verbuf_mem, verbuf_size, mrsas_addr_cb, &sc->verbuf_phys_addr, BUS_DMA_NOWAIT)) { device_printf(sc->mrsas_dev, "Cannot load verbuf DMA map\n"); return (ENOMEM); } /* * Allocate IO Request Frames */ io_req_size = sc->io_frames_alloc_sz; if (bus_dma_tag_create(sc->mrsas_parent_tag, 16, 0, BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL, io_req_size, 1, io_req_size, BUS_DMA_ALLOCNOW, NULL, NULL, &sc->io_request_tag)) { device_printf(sc->mrsas_dev, "Cannot create IO request tag\n"); return (ENOMEM); } if (bus_dmamem_alloc(sc->io_request_tag, (void **)&sc->io_request_mem, BUS_DMA_NOWAIT, &sc->io_request_dmamap)) { device_printf(sc->mrsas_dev, "Cannot alloc IO request memory\n"); return (ENOMEM); } bzero(sc->io_request_mem, io_req_size); if (bus_dmamap_load(sc->io_request_tag, sc->io_request_dmamap, sc->io_request_mem, io_req_size, mrsas_addr_cb, &sc->io_request_phys_addr, BUS_DMA_NOWAIT)) { device_printf(sc->mrsas_dev, "Cannot load IO request memory\n"); return (ENOMEM); } /* * Allocate Chain Frames */ chain_frame_size = sc->chain_frames_alloc_sz; if (bus_dma_tag_create(sc->mrsas_parent_tag, 4, 0, BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL, chain_frame_size, 1, chain_frame_size, BUS_DMA_ALLOCNOW, NULL, NULL, &sc->chain_frame_tag)) { device_printf(sc->mrsas_dev, "Cannot create chain frame tag\n"); return (ENOMEM); } if (bus_dmamem_alloc(sc->chain_frame_tag, (void **)&sc->chain_frame_mem, BUS_DMA_NOWAIT, &sc->chain_frame_dmamap)) { device_printf(sc->mrsas_dev, "Cannot alloc chain frame memory\n"); return (ENOMEM); } bzero(sc->chain_frame_mem, chain_frame_size); if (bus_dmamap_load(sc->chain_frame_tag, sc->chain_frame_dmamap, sc->chain_frame_mem, chain_frame_size, mrsas_addr_cb, &sc->chain_frame_phys_addr, BUS_DMA_NOWAIT)) { device_printf(sc->mrsas_dev, "Cannot load chain frame memory\n"); return (ENOMEM); } count = sc->msix_vectors > 0 ? sc->msix_vectors : 1; /* * Allocate Reply Descriptor Array */ reply_desc_size = sc->reply_alloc_sz * count; if (bus_dma_tag_create(sc->mrsas_parent_tag, 16, 0, BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL, reply_desc_size, 1, reply_desc_size, BUS_DMA_ALLOCNOW, NULL, NULL, &sc->reply_desc_tag)) { device_printf(sc->mrsas_dev, "Cannot create reply descriptor tag\n"); return (ENOMEM); } if (bus_dmamem_alloc(sc->reply_desc_tag, (void **)&sc->reply_desc_mem, BUS_DMA_NOWAIT, &sc->reply_desc_dmamap)) { device_printf(sc->mrsas_dev, "Cannot alloc reply descriptor memory\n"); return (ENOMEM); } if (bus_dmamap_load(sc->reply_desc_tag, sc->reply_desc_dmamap, sc->reply_desc_mem, reply_desc_size, mrsas_addr_cb, &sc->reply_desc_phys_addr, BUS_DMA_NOWAIT)) { device_printf(sc->mrsas_dev, "Cannot load reply descriptor memory\n"); return (ENOMEM); } /* * Allocate Sense Buffer Array. Keep in lower 4GB */ sense_size = sc->max_fw_cmds * MRSAS_SENSE_LEN; if (bus_dma_tag_create(sc->mrsas_parent_tag, 64, 0, BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL, sense_size, 1, sense_size, BUS_DMA_ALLOCNOW, NULL, NULL, &sc->sense_tag)) { device_printf(sc->mrsas_dev, "Cannot allocate sense buf tag\n"); return (ENOMEM); } if (bus_dmamem_alloc(sc->sense_tag, (void **)&sc->sense_mem, BUS_DMA_NOWAIT, &sc->sense_dmamap)) { device_printf(sc->mrsas_dev, "Cannot allocate sense buf memory\n"); return (ENOMEM); } if (bus_dmamap_load(sc->sense_tag, sc->sense_dmamap, sc->sense_mem, sense_size, mrsas_addr_cb, &sc->sense_phys_addr, BUS_DMA_NOWAIT)) { device_printf(sc->mrsas_dev, "Cannot load sense buf memory\n"); return (ENOMEM); } /* * Allocate for Event detail structure */ evt_detail_size = sizeof(struct mrsas_evt_detail); if (bus_dma_tag_create(sc->mrsas_parent_tag, 1, 0, BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL, evt_detail_size, 1, evt_detail_size, BUS_DMA_ALLOCNOW, NULL, NULL, &sc->evt_detail_tag)) { device_printf(sc->mrsas_dev, "Cannot create Event detail tag\n"); return (ENOMEM); } if (bus_dmamem_alloc(sc->evt_detail_tag, (void **)&sc->evt_detail_mem, BUS_DMA_NOWAIT, &sc->evt_detail_dmamap)) { device_printf(sc->mrsas_dev, "Cannot alloc Event detail buffer memory\n"); return (ENOMEM); } bzero(sc->evt_detail_mem, evt_detail_size); if (bus_dmamap_load(sc->evt_detail_tag, sc->evt_detail_dmamap, sc->evt_detail_mem, evt_detail_size, mrsas_addr_cb, &sc->evt_detail_phys_addr, BUS_DMA_NOWAIT)) { device_printf(sc->mrsas_dev, "Cannot load Event detail buffer memory\n"); return (ENOMEM); } /* * Allocate for PD INFO structure */ pd_info_size = sizeof(struct mrsas_pd_info); if (bus_dma_tag_create(sc->mrsas_parent_tag, 1, 0, BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL, pd_info_size, 1, pd_info_size, BUS_DMA_ALLOCNOW, NULL, NULL, &sc->pd_info_tag)) { device_printf(sc->mrsas_dev, "Cannot create PD INFO tag\n"); return (ENOMEM); } if (bus_dmamem_alloc(sc->pd_info_tag, (void **)&sc->pd_info_mem, BUS_DMA_NOWAIT, &sc->pd_info_dmamap)) { device_printf(sc->mrsas_dev, "Cannot alloc PD INFO buffer memory\n"); return (ENOMEM); } bzero(sc->pd_info_mem, pd_info_size); if (bus_dmamap_load(sc->pd_info_tag, sc->pd_info_dmamap, sc->pd_info_mem, pd_info_size, mrsas_addr_cb, &sc->pd_info_phys_addr, BUS_DMA_NOWAIT)) { device_printf(sc->mrsas_dev, "Cannot load PD INFO buffer memory\n"); return (ENOMEM); } /* * Create a dma tag for data buffers; size will be the maximum * possible I/O size (280kB). */ if (bus_dma_tag_create(sc->mrsas_parent_tag, 1, 0, BUS_SPACE_MAXADDR, BUS_SPACE_MAXADDR, NULL, NULL, MAXPHYS, sc->max_num_sge, /* nsegments */ MAXPHYS, BUS_DMA_ALLOCNOW, busdma_lock_mutex, &sc->io_lock, &sc->data_tag)) { device_printf(sc->mrsas_dev, "Cannot create data dma tag\n"); return (ENOMEM); } return (0); } /* * mrsas_addr_cb: Callback function of bus_dmamap_load() * input: callback argument, machine dependent type * that describes DMA segments, number of segments, error code * * This function is for the driver to receive mapping information resultant of * the bus_dmamap_load(). The information is actually not being used, but the * address is saved anyway. */ void mrsas_addr_cb(void *arg, bus_dma_segment_t *segs, int nsegs, int error) { bus_addr_t *addr; addr = arg; *addr = segs[0].ds_addr; } /* * mrsas_setup_raidmap: Set up RAID map. * input: Adapter instance soft state * * Allocate DMA memory for the RAID maps and perform setup. */ static int mrsas_setup_raidmap(struct mrsas_softc *sc) { int i; for (i = 0; i < 2; i++) { sc->ld_drv_map[i] = (void *)malloc(sc->drv_map_sz, M_MRSAS, M_NOWAIT); /* Do Error handling */ if (!sc->ld_drv_map[i]) { device_printf(sc->mrsas_dev, "Could not allocate memory for local map"); if (i == 1) free(sc->ld_drv_map[0], M_MRSAS); /* ABORT driver initialization */ goto ABORT; } } for (int i = 0; i < 2; i++) { if (bus_dma_tag_create(sc->mrsas_parent_tag, 4, 0, BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL, sc->max_map_sz, 1, sc->max_map_sz, BUS_DMA_ALLOCNOW, NULL, NULL, &sc->raidmap_tag[i])) { device_printf(sc->mrsas_dev, "Cannot allocate raid map tag.\n"); return (ENOMEM); } if (bus_dmamem_alloc(sc->raidmap_tag[i], (void **)&sc->raidmap_mem[i], BUS_DMA_NOWAIT, &sc->raidmap_dmamap[i])) { device_printf(sc->mrsas_dev, "Cannot allocate raidmap memory.\n"); return (ENOMEM); } bzero(sc->raidmap_mem[i], sc->max_map_sz); if (bus_dmamap_load(sc->raidmap_tag[i], sc->raidmap_dmamap[i], sc->raidmap_mem[i], sc->max_map_sz, mrsas_addr_cb, &sc->raidmap_phys_addr[i], BUS_DMA_NOWAIT)) { device_printf(sc->mrsas_dev, "Cannot load raidmap memory.\n"); return (ENOMEM); } if (!sc->raidmap_mem[i]) { device_printf(sc->mrsas_dev, "Cannot allocate memory for raid map.\n"); return (ENOMEM); } } if (!mrsas_get_map_info(sc)) mrsas_sync_map_info(sc); return (0); ABORT: return (1); } /** * megasas_setup_jbod_map - setup jbod map for FP seq_number. * @sc: Adapter soft state * * Return 0 on success. */ void megasas_setup_jbod_map(struct mrsas_softc *sc) { int i; uint32_t pd_seq_map_sz; pd_seq_map_sz = sizeof(struct MR_PD_CFG_SEQ_NUM_SYNC) + (sizeof(struct MR_PD_CFG_SEQ) * (MAX_PHYSICAL_DEVICES - 1)); if (!sc->ctrl_info->adapterOperations3.useSeqNumJbodFP) { sc->use_seqnum_jbod_fp = 0; return; } if (sc->jbodmap_mem[0]) goto skip_alloc; for (i = 0; i < 2; i++) { if (bus_dma_tag_create(sc->mrsas_parent_tag, 4, 0, BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL, pd_seq_map_sz, 1, pd_seq_map_sz, BUS_DMA_ALLOCNOW, NULL, NULL, &sc->jbodmap_tag[i])) { device_printf(sc->mrsas_dev, "Cannot allocate jbod map tag.\n"); return; } if (bus_dmamem_alloc(sc->jbodmap_tag[i], (void **)&sc->jbodmap_mem[i], BUS_DMA_NOWAIT, &sc->jbodmap_dmamap[i])) { device_printf(sc->mrsas_dev, "Cannot allocate jbod map memory.\n"); return; } bzero(sc->jbodmap_mem[i], pd_seq_map_sz); if (bus_dmamap_load(sc->jbodmap_tag[i], sc->jbodmap_dmamap[i], sc->jbodmap_mem[i], pd_seq_map_sz, mrsas_addr_cb, &sc->jbodmap_phys_addr[i], BUS_DMA_NOWAIT)) { device_printf(sc->mrsas_dev, "Cannot load jbod map memory.\n"); return; } if (!sc->jbodmap_mem[i]) { device_printf(sc->mrsas_dev, "Cannot allocate memory for jbod map.\n"); sc->use_seqnum_jbod_fp = 0; return; } } skip_alloc: if (!megasas_sync_pd_seq_num(sc, false) && !megasas_sync_pd_seq_num(sc, true)) sc->use_seqnum_jbod_fp = 1; else sc->use_seqnum_jbod_fp = 0; device_printf(sc->mrsas_dev, "Jbod map is supported\n"); } /* * mrsas_init_fw: Initialize Firmware * input: Adapter soft state * * Calls transition_to_ready() to make sure Firmware is in operational state and * calls mrsas_init_adapter() to send IOC_INIT command to Firmware. It * issues internal commands to get the controller info after the IOC_INIT * command response is received by Firmware. Note: code relating to * get_pdlist, get_ld_list and max_sectors are currently not being used, it * is left here as placeholder. */ static int mrsas_init_fw(struct mrsas_softc *sc) { int ret, loop, ocr = 0; u_int32_t max_sectors_1; u_int32_t max_sectors_2; u_int32_t tmp_sectors; u_int32_t scratch_pad_2, scratch_pad_3, scratch_pad_4; int msix_enable = 0; int fw_msix_count = 0; int i, j; /* Make sure Firmware is ready */ ret = mrsas_transition_to_ready(sc, ocr); if (ret != SUCCESS) { return (ret); } if (sc->is_ventura || sc->is_aero) { scratch_pad_3 = mrsas_read_reg_with_retries(sc, offsetof(mrsas_reg_set, outbound_scratch_pad_3)); #if VD_EXT_DEBUG device_printf(sc->mrsas_dev, "scratch_pad_3 0x%x\n", scratch_pad_3); #endif sc->maxRaidMapSize = ((scratch_pad_3 >> MR_MAX_RAID_MAP_SIZE_OFFSET_SHIFT) & MR_MAX_RAID_MAP_SIZE_MASK); } /* MSI-x index 0- reply post host index register */ sc->msix_reg_offset[0] = MPI2_REPLY_POST_HOST_INDEX_OFFSET; /* Check if MSI-X is supported while in ready state */ msix_enable = (mrsas_read_reg_with_retries(sc, offsetof(mrsas_reg_set, outbound_scratch_pad)) & 0x4000000) >> 0x1a; if (msix_enable) { scratch_pad_2 = mrsas_read_reg_with_retries(sc, offsetof(mrsas_reg_set, outbound_scratch_pad_2)); /* Check max MSI-X vectors */ if (sc->device_id == MRSAS_TBOLT) { sc->msix_vectors = (scratch_pad_2 & MR_MAX_REPLY_QUEUES_OFFSET) + 1; fw_msix_count = sc->msix_vectors; } else { /* Invader/Fury supports 96 MSI-X vectors */ sc->msix_vectors = ((scratch_pad_2 & MR_MAX_REPLY_QUEUES_EXT_OFFSET) >> MR_MAX_REPLY_QUEUES_EXT_OFFSET_SHIFT) + 1; fw_msix_count = sc->msix_vectors; if ((sc->mrsas_gen3_ctrl && (sc->msix_vectors > 8)) || ((sc->is_ventura || sc->is_aero) && (sc->msix_vectors > 16))) sc->msix_combined = true; /* * Save 1-15 reply post index * address to local memory Index 0 * is already saved from reg offset * MPI2_REPLY_POST_HOST_INDEX_OFFSET */ for (loop = 1; loop < MR_MAX_MSIX_REG_ARRAY; loop++) { sc->msix_reg_offset[loop] = MPI2_SUP_REPLY_POST_HOST_INDEX_OFFSET + (loop * 0x10); } } /* Don't bother allocating more MSI-X vectors than cpus */ sc->msix_vectors = min(sc->msix_vectors, mp_ncpus); /* Allocate MSI-x vectors */ if (mrsas_allocate_msix(sc) == SUCCESS) sc->msix_enable = 1; else sc->msix_enable = 0; device_printf(sc->mrsas_dev, "FW supports <%d> MSIX vector," "Online CPU %d Current MSIX <%d>\n", fw_msix_count, mp_ncpus, sc->msix_vectors); } /* * MSI-X host index 0 is common for all adapter. * It is used for all MPT based Adapters. */ if (sc->msix_combined) { sc->msix_reg_offset[0] = MPI2_SUP_REPLY_POST_HOST_INDEX_OFFSET; } if (mrsas_init_adapter(sc) != SUCCESS) { device_printf(sc->mrsas_dev, "Adapter initialize Fail.\n"); return (1); } if (sc->is_ventura || sc->is_aero) { scratch_pad_4 = mrsas_read_reg_with_retries(sc, offsetof(mrsas_reg_set, outbound_scratch_pad_4)); if ((scratch_pad_4 & MR_NVME_PAGE_SIZE_MASK) >= MR_DEFAULT_NVME_PAGE_SHIFT) sc->nvme_page_size = 1 << (scratch_pad_4 & MR_NVME_PAGE_SIZE_MASK); device_printf(sc->mrsas_dev, "NVME page size\t: (%d)\n", sc->nvme_page_size); } /* Allocate internal commands for pass-thru */ if (mrsas_alloc_mfi_cmds(sc) != SUCCESS) { device_printf(sc->mrsas_dev, "Allocate MFI cmd failed.\n"); return (1); } sc->ctrl_info = malloc(sizeof(struct mrsas_ctrl_info), M_MRSAS, M_NOWAIT); if (!sc->ctrl_info) { device_printf(sc->mrsas_dev, "Malloc for ctrl_info failed.\n"); return (1); } /* * Get the controller info from FW, so that the MAX VD support * availability can be decided. */ if (mrsas_get_ctrl_info(sc)) { device_printf(sc->mrsas_dev, "Unable to get FW ctrl_info.\n"); return (1); } sc->secure_jbod_support = (u_int8_t)sc->ctrl_info->adapterOperations3.supportSecurityonJBOD; if (sc->secure_jbod_support) device_printf(sc->mrsas_dev, "FW supports SED \n"); if (sc->use_seqnum_jbod_fp) device_printf(sc->mrsas_dev, "FW supports JBOD Map \n"); if (sc->support_morethan256jbod) device_printf(sc->mrsas_dev, "FW supports JBOD Map Ext \n"); if (mrsas_setup_raidmap(sc) != SUCCESS) { device_printf(sc->mrsas_dev, "Error: RAID map setup FAILED !!! " "There seems to be some problem in the controller\n" "Please contact to the SUPPORT TEAM if the problem persists\n"); } megasas_setup_jbod_map(sc); memset(sc->target_list, 0, MRSAS_MAX_TM_TARGETS * sizeof(struct mrsas_target)); for (i = 0; i < MRSAS_MAX_TM_TARGETS; i++) sc->target_list[i].target_id = 0xffff; /* For pass-thru, get PD/LD list and controller info */ memset(sc->pd_list, 0, MRSAS_MAX_PD * sizeof(struct mrsas_pd_list)); if (mrsas_get_pd_list(sc) != SUCCESS) { device_printf(sc->mrsas_dev, "Get PD list failed.\n"); return (1); } memset(sc->ld_ids, 0xff, MRSAS_MAX_LD_IDS); if (mrsas_get_ld_list(sc) != SUCCESS) { device_printf(sc->mrsas_dev, "Get LD lsit failed.\n"); return (1); } if ((sc->is_ventura || sc->is_aero) && sc->drv_stream_detection) { sc->streamDetectByLD = malloc(sizeof(PTR_LD_STREAM_DETECT) * MAX_LOGICAL_DRIVES_EXT, M_MRSAS, M_NOWAIT); if (!sc->streamDetectByLD) { device_printf(sc->mrsas_dev, "unable to allocate stream detection for pool of LDs\n"); return (1); } for (i = 0; i < MAX_LOGICAL_DRIVES_EXT; ++i) { sc->streamDetectByLD[i] = malloc(sizeof(LD_STREAM_DETECT), M_MRSAS, M_NOWAIT); if (!sc->streamDetectByLD[i]) { device_printf(sc->mrsas_dev, "unable to allocate stream detect by LD\n"); for (j = 0; j < i; ++j) free(sc->streamDetectByLD[j], M_MRSAS); free(sc->streamDetectByLD, M_MRSAS); sc->streamDetectByLD = NULL; return (1); } memset(sc->streamDetectByLD[i], 0, sizeof(LD_STREAM_DETECT)); sc->streamDetectByLD[i]->mruBitMap = MR_STREAM_BITMAP; } } /* * Compute the max allowed sectors per IO: The controller info has * two limits on max sectors. Driver should use the minimum of these * two. * * 1 << stripe_sz_ops.min = max sectors per strip * * Note that older firmwares ( < FW ver 30) didn't report information to * calculate max_sectors_1. So the number ended up as zero always. */ tmp_sectors = 0; max_sectors_1 = (1 << sc->ctrl_info->stripe_sz_ops.min) * sc->ctrl_info->max_strips_per_io; max_sectors_2 = sc->ctrl_info->max_request_size; tmp_sectors = min(max_sectors_1, max_sectors_2); sc->max_sectors_per_req = sc->max_num_sge * MRSAS_PAGE_SIZE / 512; if (tmp_sectors && (sc->max_sectors_per_req > tmp_sectors)) sc->max_sectors_per_req = tmp_sectors; sc->disableOnlineCtrlReset = sc->ctrl_info->properties.OnOffProperties.disableOnlineCtrlReset; sc->UnevenSpanSupport = sc->ctrl_info->adapterOperations2.supportUnevenSpans; if (sc->UnevenSpanSupport) { device_printf(sc->mrsas_dev, "FW supports: UnevenSpanSupport=%x\n\n", sc->UnevenSpanSupport); if (MR_ValidateMapInfo(sc)) sc->fast_path_io = 1; else sc->fast_path_io = 0; } device_printf(sc->mrsas_dev, "max_fw_cmds: %u max_scsi_cmds: %u\n", sc->max_fw_cmds, sc->max_scsi_cmds); return (0); } /* * mrsas_init_adapter: Initializes the adapter/controller * input: Adapter soft state * * Prepares for the issuing of the IOC Init cmd to FW for initializing the * ROC/controller. The FW register is read to determined the number of * commands that is supported. All memory allocations for IO is based on * max_cmd. Appropriate calculations are performed in this function. */ int mrsas_init_adapter(struct mrsas_softc *sc) { uint32_t status; u_int32_t scratch_pad_2; int ret; int i = 0; /* Read FW status register */ status = mrsas_read_reg_with_retries(sc, offsetof(mrsas_reg_set, outbound_scratch_pad)); sc->max_fw_cmds = status & MRSAS_FWSTATE_MAXCMD_MASK; /* Decrement the max supported by 1, to correlate with FW */ sc->max_fw_cmds = sc->max_fw_cmds - 1; sc->max_scsi_cmds = sc->max_fw_cmds - MRSAS_MAX_MFI_CMDS; /* Determine allocation size of command frames */ sc->reply_q_depth = ((sc->max_fw_cmds + 1 + 15) / 16 * 16) * 2; sc->request_alloc_sz = sizeof(MRSAS_REQUEST_DESCRIPTOR_UNION) * sc->max_fw_cmds; sc->reply_alloc_sz = sizeof(MPI2_REPLY_DESCRIPTORS_UNION) * (sc->reply_q_depth); sc->io_frames_alloc_sz = MRSAS_MPI2_RAID_DEFAULT_IO_FRAME_SIZE + (MRSAS_MPI2_RAID_DEFAULT_IO_FRAME_SIZE * (sc->max_fw_cmds + 1)); scratch_pad_2 = mrsas_read_reg_with_retries(sc, offsetof(mrsas_reg_set, outbound_scratch_pad_2)); /* * If scratch_pad_2 & MEGASAS_MAX_CHAIN_SIZE_UNITS_MASK is set, * Firmware support extended IO chain frame which is 4 time more * than legacy Firmware. Legacy Firmware - Frame size is (8 * 128) = * 1K 1M IO Firmware - Frame size is (8 * 128 * 4) = 4K */ if (scratch_pad_2 & MEGASAS_MAX_CHAIN_SIZE_UNITS_MASK) sc->max_chain_frame_sz = ((scratch_pad_2 & MEGASAS_MAX_CHAIN_SIZE_MASK) >> 5) * MEGASAS_1MB_IO; else sc->max_chain_frame_sz = ((scratch_pad_2 & MEGASAS_MAX_CHAIN_SIZE_MASK) >> 5) * MEGASAS_256K_IO; sc->chain_frames_alloc_sz = sc->max_chain_frame_sz * sc->max_fw_cmds; sc->max_sge_in_main_msg = (MRSAS_MPI2_RAID_DEFAULT_IO_FRAME_SIZE - offsetof(MRSAS_RAID_SCSI_IO_REQUEST, SGL)) / 16; sc->max_sge_in_chain = sc->max_chain_frame_sz / sizeof(MPI2_SGE_IO_UNION); sc->max_num_sge = sc->max_sge_in_main_msg + sc->max_sge_in_chain - 2; mrsas_dprint(sc, MRSAS_INFO, "max sge: 0x%x, max chain frame size: 0x%x, " "max fw cmd: 0x%x\n", sc->max_num_sge, sc->max_chain_frame_sz, sc->max_fw_cmds); /* Used for pass thru MFI frame (DCMD) */ sc->chain_offset_mfi_pthru = offsetof(MRSAS_RAID_SCSI_IO_REQUEST, SGL) / 16; sc->chain_offset_io_request = (MRSAS_MPI2_RAID_DEFAULT_IO_FRAME_SIZE - sizeof(MPI2_SGE_IO_UNION)) / 16; int count = sc->msix_vectors > 0 ? sc->msix_vectors : 1; for (i = 0; i < count; i++) sc->last_reply_idx[i] = 0; ret = mrsas_alloc_mem(sc); if (ret != SUCCESS) return (ret); ret = mrsas_alloc_mpt_cmds(sc); if (ret != SUCCESS) return (ret); ret = mrsas_ioc_init(sc); if (ret != SUCCESS) return (ret); return (0); } /* * mrsas_alloc_ioc_cmd: Allocates memory for IOC Init command * input: Adapter soft state * * Allocates for the IOC Init cmd to FW to initialize the ROC/controller. */ int mrsas_alloc_ioc_cmd(struct mrsas_softc *sc) { int ioc_init_size; /* Allocate IOC INIT command */ ioc_init_size = 1024 + sizeof(MPI2_IOC_INIT_REQUEST); if (bus_dma_tag_create(sc->mrsas_parent_tag, 1, 0, BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL, ioc_init_size, 1, ioc_init_size, BUS_DMA_ALLOCNOW, NULL, NULL, &sc->ioc_init_tag)) { device_printf(sc->mrsas_dev, "Cannot allocate ioc init tag\n"); return (ENOMEM); } if (bus_dmamem_alloc(sc->ioc_init_tag, (void **)&sc->ioc_init_mem, BUS_DMA_NOWAIT, &sc->ioc_init_dmamap)) { device_printf(sc->mrsas_dev, "Cannot allocate ioc init cmd mem\n"); return (ENOMEM); } bzero(sc->ioc_init_mem, ioc_init_size); if (bus_dmamap_load(sc->ioc_init_tag, sc->ioc_init_dmamap, sc->ioc_init_mem, ioc_init_size, mrsas_addr_cb, &sc->ioc_init_phys_mem, BUS_DMA_NOWAIT)) { device_printf(sc->mrsas_dev, "Cannot load ioc init cmd mem\n"); return (ENOMEM); } return (0); } /* * mrsas_free_ioc_cmd: Allocates memory for IOC Init command * input: Adapter soft state * * Deallocates memory of the IOC Init cmd. */ void mrsas_free_ioc_cmd(struct mrsas_softc *sc) { if (sc->ioc_init_phys_mem) bus_dmamap_unload(sc->ioc_init_tag, sc->ioc_init_dmamap); if (sc->ioc_init_mem != NULL) bus_dmamem_free(sc->ioc_init_tag, sc->ioc_init_mem, sc->ioc_init_dmamap); if (sc->ioc_init_tag != NULL) bus_dma_tag_destroy(sc->ioc_init_tag); } /* * mrsas_ioc_init: Sends IOC Init command to FW * input: Adapter soft state * * Issues the IOC Init cmd to FW to initialize the ROC/controller. */ int mrsas_ioc_init(struct mrsas_softc *sc) { struct mrsas_init_frame *init_frame; pMpi2IOCInitRequest_t IOCInitMsg; MRSAS_REQUEST_DESCRIPTOR_UNION req_desc; u_int8_t max_wait = MRSAS_INTERNAL_CMD_WAIT_TIME; bus_addr_t phys_addr; int i, retcode = 0; u_int32_t scratch_pad_2; /* Allocate memory for the IOC INIT command */ if (mrsas_alloc_ioc_cmd(sc)) { device_printf(sc->mrsas_dev, "Cannot allocate IOC command.\n"); return (1); } if (!sc->block_sync_cache) { scratch_pad_2 = mrsas_read_reg_with_retries(sc, offsetof(mrsas_reg_set, outbound_scratch_pad_2)); sc->fw_sync_cache_support = (scratch_pad_2 & MR_CAN_HANDLE_SYNC_CACHE_OFFSET) ? 1 : 0; } IOCInitMsg = (pMpi2IOCInitRequest_t)(((char *)sc->ioc_init_mem) + 1024); IOCInitMsg->Function = MPI2_FUNCTION_IOC_INIT; IOCInitMsg->WhoInit = MPI2_WHOINIT_HOST_DRIVER; IOCInitMsg->MsgVersion = MPI2_VERSION; IOCInitMsg->HeaderVersion = MPI2_HEADER_VERSION; IOCInitMsg->SystemRequestFrameSize = MRSAS_MPI2_RAID_DEFAULT_IO_FRAME_SIZE / 4; IOCInitMsg->ReplyDescriptorPostQueueDepth = sc->reply_q_depth; IOCInitMsg->ReplyDescriptorPostQueueAddress = sc->reply_desc_phys_addr; IOCInitMsg->SystemRequestFrameBaseAddress = sc->io_request_phys_addr; IOCInitMsg->HostMSIxVectors = (sc->msix_vectors > 0 ? sc->msix_vectors : 0); IOCInitMsg->HostPageSize = MR_DEFAULT_NVME_PAGE_SHIFT; init_frame = (struct mrsas_init_frame *)sc->ioc_init_mem; init_frame->cmd = MFI_CMD_INIT; init_frame->cmd_status = 0xFF; init_frame->flags |= MFI_FRAME_DONT_POST_IN_REPLY_QUEUE; /* driver support Extended MSIX */ if (sc->mrsas_gen3_ctrl || sc->is_ventura || sc->is_aero) { init_frame->driver_operations. mfi_capabilities.support_additional_msix = 1; } if (sc->verbuf_mem) { snprintf((char *)sc->verbuf_mem, strlen(MRSAS_VERSION) + 2, "%s\n", MRSAS_VERSION); init_frame->driver_ver_lo = (bus_addr_t)sc->verbuf_phys_addr; init_frame->driver_ver_hi = 0; } init_frame->driver_operations.mfi_capabilities.support_ndrive_r1_lb = 1; init_frame->driver_operations.mfi_capabilities.support_max_255lds = 1; init_frame->driver_operations.mfi_capabilities.security_protocol_cmds_fw = 1; if (sc->max_chain_frame_sz > MEGASAS_CHAIN_FRAME_SZ_MIN) init_frame->driver_operations.mfi_capabilities.support_ext_io_size = 1; phys_addr = (bus_addr_t)sc->ioc_init_phys_mem + 1024; init_frame->queue_info_new_phys_addr_lo = phys_addr; init_frame->data_xfer_len = sizeof(Mpi2IOCInitRequest_t); req_desc.addr.Words = (bus_addr_t)sc->ioc_init_phys_mem; req_desc.MFAIo.RequestFlags = (MRSAS_REQ_DESCRIPT_FLAGS_MFA << MRSAS_REQ_DESCRIPT_FLAGS_TYPE_SHIFT); mrsas_disable_intr(sc); mrsas_dprint(sc, MRSAS_OCR, "Issuing IOC INIT command to FW.\n"); mrsas_write_64bit_req_desc(sc, req_desc.addr.u.low, req_desc.addr.u.high); /* * Poll response timer to wait for Firmware response. While this * timer with the DELAY call could block CPU, the time interval for * this is only 1 millisecond. */ if (init_frame->cmd_status == 0xFF) { for (i = 0; i < (max_wait * 1000); i++) { if (init_frame->cmd_status == 0xFF) DELAY(1000); else break; } } if (init_frame->cmd_status == 0) mrsas_dprint(sc, MRSAS_OCR, "IOC INIT response received from FW.\n"); else { if (init_frame->cmd_status == 0xFF) device_printf(sc->mrsas_dev, "IOC Init timed out after %d seconds.\n", max_wait); else device_printf(sc->mrsas_dev, "IOC Init failed, status = 0x%x\n", init_frame->cmd_status); retcode = 1; } if (sc->is_aero) { scratch_pad_2 = mrsas_read_reg_with_retries(sc, offsetof(mrsas_reg_set, outbound_scratch_pad_2)); sc->atomic_desc_support = (scratch_pad_2 & MR_ATOMIC_DESCRIPTOR_SUPPORT_OFFSET) ? 1 : 0; device_printf(sc->mrsas_dev, "FW supports atomic descriptor: %s\n", sc->atomic_desc_support ? "Yes" : "No"); } mrsas_free_ioc_cmd(sc); return (retcode); } /* * mrsas_alloc_mpt_cmds: Allocates the command packets * input: Adapter instance soft state * * This function allocates the internal commands for IOs. Each command that is * issued to FW is wrapped in a local data structure called mrsas_mpt_cmd. An * array is allocated with mrsas_mpt_cmd context. The free commands are * maintained in a linked list (cmd pool). SMID value range is from 1 to * max_fw_cmds. */ int mrsas_alloc_mpt_cmds(struct mrsas_softc *sc) { int i, j; u_int32_t max_fw_cmds, count; struct mrsas_mpt_cmd *cmd; pMpi2ReplyDescriptorsUnion_t reply_desc; u_int32_t offset, chain_offset, sense_offset; bus_addr_t io_req_base_phys, chain_frame_base_phys, sense_base_phys; u_int8_t *io_req_base, *chain_frame_base, *sense_base; max_fw_cmds = sc->max_fw_cmds; sc->req_desc = malloc(sc->request_alloc_sz, M_MRSAS, M_NOWAIT); if (!sc->req_desc) { device_printf(sc->mrsas_dev, "Out of memory, cannot alloc req desc\n"); return (ENOMEM); } memset(sc->req_desc, 0, sc->request_alloc_sz); /* * sc->mpt_cmd_list is an array of struct mrsas_mpt_cmd pointers. * Allocate the dynamic array first and then allocate individual * commands. */ sc->mpt_cmd_list = malloc(sizeof(struct mrsas_mpt_cmd *) * max_fw_cmds, M_MRSAS, M_NOWAIT); if (!sc->mpt_cmd_list) { device_printf(sc->mrsas_dev, "Cannot alloc memory for mpt_cmd_list.\n"); return (ENOMEM); } memset(sc->mpt_cmd_list, 0, sizeof(struct mrsas_mpt_cmd *) * max_fw_cmds); for (i = 0; i < max_fw_cmds; i++) { sc->mpt_cmd_list[i] = malloc(sizeof(struct mrsas_mpt_cmd), M_MRSAS, M_NOWAIT); if (!sc->mpt_cmd_list[i]) { for (j = 0; j < i; j++) free(sc->mpt_cmd_list[j], M_MRSAS); free(sc->mpt_cmd_list, M_MRSAS); sc->mpt_cmd_list = NULL; return (ENOMEM); } } io_req_base = (u_int8_t *)sc->io_request_mem + MRSAS_MPI2_RAID_DEFAULT_IO_FRAME_SIZE; io_req_base_phys = (bus_addr_t)sc->io_request_phys_addr + MRSAS_MPI2_RAID_DEFAULT_IO_FRAME_SIZE; chain_frame_base = (u_int8_t *)sc->chain_frame_mem; chain_frame_base_phys = (bus_addr_t)sc->chain_frame_phys_addr; sense_base = (u_int8_t *)sc->sense_mem; sense_base_phys = (bus_addr_t)sc->sense_phys_addr; for (i = 0; i < max_fw_cmds; i++) { cmd = sc->mpt_cmd_list[i]; offset = MRSAS_MPI2_RAID_DEFAULT_IO_FRAME_SIZE * i; chain_offset = sc->max_chain_frame_sz * i; sense_offset = MRSAS_SENSE_LEN * i; memset(cmd, 0, sizeof(struct mrsas_mpt_cmd)); cmd->index = i + 1; cmd->ccb_ptr = NULL; cmd->r1_alt_dev_handle = MR_DEVHANDLE_INVALID; callout_init_mtx(&cmd->cm_callout, &sc->sim_lock, 0); cmd->sync_cmd_idx = (u_int32_t)MRSAS_ULONG_MAX; cmd->sc = sc; cmd->io_request = (MRSAS_RAID_SCSI_IO_REQUEST *) (io_req_base + offset); memset(cmd->io_request, 0, sizeof(MRSAS_RAID_SCSI_IO_REQUEST)); cmd->io_request_phys_addr = io_req_base_phys + offset; cmd->chain_frame = (MPI2_SGE_IO_UNION *) (chain_frame_base + chain_offset); cmd->chain_frame_phys_addr = chain_frame_base_phys + chain_offset; cmd->sense = sense_base + sense_offset; cmd->sense_phys_addr = sense_base_phys + sense_offset; if (bus_dmamap_create(sc->data_tag, 0, &cmd->data_dmamap)) { return (FAIL); } TAILQ_INSERT_TAIL(&(sc->mrsas_mpt_cmd_list_head), cmd, next); } /* Initialize reply descriptor array to 0xFFFFFFFF */ reply_desc = sc->reply_desc_mem; count = sc->msix_vectors > 0 ? sc->msix_vectors : 1; for (i = 0; i < sc->reply_q_depth * count; i++, reply_desc++) { reply_desc->Words = MRSAS_ULONG_MAX; } return (0); } /* * mrsas_write_64bit_req_dsc: Writes 64 bit request descriptor to FW * input: Adapter softstate * request descriptor address low * request descriptor address high */ void mrsas_write_64bit_req_desc(struct mrsas_softc *sc, u_int32_t req_desc_lo, u_int32_t req_desc_hi) { mtx_lock(&sc->pci_lock); mrsas_write_reg(sc, offsetof(mrsas_reg_set, inbound_low_queue_port), req_desc_lo); mrsas_write_reg(sc, offsetof(mrsas_reg_set, inbound_high_queue_port), req_desc_hi); mtx_unlock(&sc->pci_lock); } /* * mrsas_fire_cmd: Sends command to FW * input: Adapter softstate * request descriptor address low * request descriptor address high * * This functions fires the command to Firmware by writing to the * inbound_low_queue_port and inbound_high_queue_port. */ void mrsas_fire_cmd(struct mrsas_softc *sc, u_int32_t req_desc_lo, u_int32_t req_desc_hi) { if (sc->atomic_desc_support) mrsas_write_reg(sc, offsetof(mrsas_reg_set, inbound_single_queue_port), req_desc_lo); else mrsas_write_64bit_req_desc(sc, req_desc_lo, req_desc_hi); } /* * mrsas_transition_to_ready: Move FW to Ready state input: * Adapter instance soft state * * During the initialization, FW passes can potentially be in any one of several * possible states. If the FW in operational, waiting-for-handshake states, * driver must take steps to bring it to ready state. Otherwise, it has to * wait for the ready state. */ int mrsas_transition_to_ready(struct mrsas_softc *sc, int ocr) { int i; u_int8_t max_wait; u_int32_t val, fw_state; u_int32_t cur_state; u_int32_t abs_state, curr_abs_state; val = mrsas_read_reg_with_retries(sc, offsetof(mrsas_reg_set, outbound_scratch_pad)); fw_state = val & MFI_STATE_MASK; max_wait = MRSAS_RESET_WAIT_TIME; if (fw_state != MFI_STATE_READY) device_printf(sc->mrsas_dev, "Waiting for FW to come to ready state\n"); while (fw_state != MFI_STATE_READY) { abs_state = mrsas_read_reg_with_retries(sc, offsetof(mrsas_reg_set, outbound_scratch_pad)); switch (fw_state) { case MFI_STATE_FAULT: device_printf(sc->mrsas_dev, "FW is in FAULT state!!\n"); if (ocr) { cur_state = MFI_STATE_FAULT; break; } else return -ENODEV; case MFI_STATE_WAIT_HANDSHAKE: /* Set the CLR bit in inbound doorbell */ mrsas_write_reg(sc, offsetof(mrsas_reg_set, doorbell), MFI_INIT_CLEAR_HANDSHAKE | MFI_INIT_HOTPLUG); cur_state = MFI_STATE_WAIT_HANDSHAKE; break; case MFI_STATE_BOOT_MESSAGE_PENDING: mrsas_write_reg(sc, offsetof(mrsas_reg_set, doorbell), MFI_INIT_HOTPLUG); cur_state = MFI_STATE_BOOT_MESSAGE_PENDING; break; case MFI_STATE_OPERATIONAL: /* * Bring it to READY state; assuming max wait 10 * secs */ mrsas_disable_intr(sc); mrsas_write_reg(sc, offsetof(mrsas_reg_set, doorbell), MFI_RESET_FLAGS); for (i = 0; i < max_wait * 1000; i++) { if (mrsas_read_reg_with_retries(sc, offsetof(mrsas_reg_set, doorbell)) & 1) DELAY(1000); else break; } cur_state = MFI_STATE_OPERATIONAL; break; case MFI_STATE_UNDEFINED: /* * This state should not last for more than 2 * seconds */ cur_state = MFI_STATE_UNDEFINED; break; case MFI_STATE_BB_INIT: cur_state = MFI_STATE_BB_INIT; break; case MFI_STATE_FW_INIT: cur_state = MFI_STATE_FW_INIT; break; case MFI_STATE_FW_INIT_2: cur_state = MFI_STATE_FW_INIT_2; break; case MFI_STATE_DEVICE_SCAN: cur_state = MFI_STATE_DEVICE_SCAN; break; case MFI_STATE_FLUSH_CACHE: cur_state = MFI_STATE_FLUSH_CACHE; break; default: device_printf(sc->mrsas_dev, "Unknown state 0x%x\n", fw_state); return -ENODEV; } /* * The cur_state should not last for more than max_wait secs */ for (i = 0; i < (max_wait * 1000); i++) { fw_state = (mrsas_read_reg_with_retries(sc, offsetof(mrsas_reg_set, outbound_scratch_pad)) & MFI_STATE_MASK); curr_abs_state = mrsas_read_reg_with_retries(sc, offsetof(mrsas_reg_set, outbound_scratch_pad)); if (abs_state == curr_abs_state) DELAY(1000); else break; } /* * Return error if fw_state hasn't changed after max_wait */ if (curr_abs_state == abs_state) { device_printf(sc->mrsas_dev, "FW state [%d] hasn't changed " "in %d secs\n", fw_state, max_wait); return -ENODEV; } } mrsas_dprint(sc, MRSAS_OCR, "FW now in Ready state\n"); return 0; } /* * mrsas_get_mfi_cmd: Get a cmd from free command pool * input: Adapter soft state * * This function removes an MFI command from the command list. */ struct mrsas_mfi_cmd * mrsas_get_mfi_cmd(struct mrsas_softc *sc) { struct mrsas_mfi_cmd *cmd = NULL; mtx_lock(&sc->mfi_cmd_pool_lock); if (!TAILQ_EMPTY(&sc->mrsas_mfi_cmd_list_head)) { cmd = TAILQ_FIRST(&sc->mrsas_mfi_cmd_list_head); TAILQ_REMOVE(&sc->mrsas_mfi_cmd_list_head, cmd, next); } mtx_unlock(&sc->mfi_cmd_pool_lock); return cmd; } /* * mrsas_ocr_thread: Thread to handle OCR/Kill Adapter. * input: Adapter Context. * * This function will check FW status register and flag do_timeout_reset flag. * It will do OCR/Kill adapter if FW is in fault state or IO timed out has * trigger reset. */ static void mrsas_ocr_thread(void *arg) { struct mrsas_softc *sc; u_int32_t fw_status, fw_state; u_int8_t tm_target_reset_failed = 0; sc = (struct mrsas_softc *)arg; mrsas_dprint(sc, MRSAS_TRACE, "%s\n", __func__); sc->ocr_thread_active = 1; mtx_lock(&sc->sim_lock); for (;;) { /* Sleep for 1 second and check the queue status */ msleep(&sc->ocr_chan, &sc->sim_lock, PRIBIO, "mrsas_ocr", sc->mrsas_fw_fault_check_delay * hz); if (sc->remove_in_progress || sc->adprecovery == MRSAS_HW_CRITICAL_ERROR) { mrsas_dprint(sc, MRSAS_OCR, "Exit due to %s from %s\n", sc->remove_in_progress ? "Shutdown" : "Hardware critical error", __func__); break; } fw_status = mrsas_read_reg_with_retries(sc, offsetof(mrsas_reg_set, outbound_scratch_pad)); fw_state = fw_status & MFI_STATE_MASK; if (fw_state == MFI_STATE_FAULT || sc->do_timedout_reset || mrsas_atomic_read(&sc->target_reset_outstanding)) { /* First, freeze further IOs to come to the SIM */ mrsas_xpt_freeze(sc); /* If this is an IO timeout then go for target reset */ if (mrsas_atomic_read(&sc->target_reset_outstanding)) { device_printf(sc->mrsas_dev, "Initiating Target RESET " "because of SCSI IO timeout!\n"); /* Let the remaining IOs to complete */ msleep(&sc->ocr_chan, &sc->sim_lock, PRIBIO, "mrsas_reset_targets", 5 * hz); /* Try to reset the target device */ if (mrsas_reset_targets(sc) == FAIL) tm_target_reset_failed = 1; } /* If this is a DCMD timeout or FW fault, * then go for controller reset */ if (fw_state == MFI_STATE_FAULT || tm_target_reset_failed || (sc->do_timedout_reset == MFI_DCMD_TIMEOUT_OCR)) { if (tm_target_reset_failed) device_printf(sc->mrsas_dev, "Initiaiting OCR because of " "TM FAILURE!\n"); else device_printf(sc->mrsas_dev, "Initiaiting OCR " "because of %s!\n", sc->do_timedout_reset ? "DCMD IO Timeout" : "FW fault"); mtx_lock_spin(&sc->ioctl_lock); sc->reset_in_progress = 1; mtx_unlock_spin(&sc->ioctl_lock); sc->reset_count++; /* * Wait for the AEN task to be completed if it is running. */ mtx_unlock(&sc->sim_lock); taskqueue_drain(sc->ev_tq, &sc->ev_task); mtx_lock(&sc->sim_lock); taskqueue_block(sc->ev_tq); /* Try to reset the controller */ mrsas_reset_ctrl(sc, sc->do_timedout_reset); sc->do_timedout_reset = 0; sc->reset_in_progress = 0; tm_target_reset_failed = 0; mrsas_atomic_set(&sc->target_reset_outstanding, 0); memset(sc->target_reset_pool, 0, sizeof(sc->target_reset_pool)); taskqueue_unblock(sc->ev_tq); } /* Now allow IOs to come to the SIM */ mrsas_xpt_release(sc); } } mtx_unlock(&sc->sim_lock); sc->ocr_thread_active = 0; mrsas_kproc_exit(0); } /* * mrsas_reset_reply_desc: Reset Reply descriptor as part of OCR. * input: Adapter Context. * * This function will clear reply descriptor so that post OCR driver and FW will * lost old history. */ void mrsas_reset_reply_desc(struct mrsas_softc *sc) { int i, count; pMpi2ReplyDescriptorsUnion_t reply_desc; count = sc->msix_vectors > 0 ? sc->msix_vectors : 1; for (i = 0; i < count; i++) sc->last_reply_idx[i] = 0; reply_desc = sc->reply_desc_mem; for (i = 0; i < sc->reply_q_depth; i++, reply_desc++) { reply_desc->Words = MRSAS_ULONG_MAX; } } /* * mrsas_reset_ctrl: Core function to OCR/Kill adapter. * input: Adapter Context. * * This function will run from thread context so that it can sleep. 1. Do not * handle OCR if FW is in HW critical error. 2. Wait for outstanding command * to complete for 180 seconds. 3. If #2 does not find any outstanding * command Controller is in working state, so skip OCR. Otherwise, do * OCR/kill Adapter based on flag disableOnlineCtrlReset. 4. Start of the * OCR, return all SCSI command back to CAM layer which has ccb_ptr. 5. Post * OCR, Re-fire Management command and move Controller to Operation state. */ int mrsas_reset_ctrl(struct mrsas_softc *sc, u_int8_t reset_reason) { int retval = SUCCESS, i, j, retry = 0; u_int32_t host_diag, abs_state, status_reg, reset_adapter; union ccb *ccb; struct mrsas_mfi_cmd *mfi_cmd; struct mrsas_mpt_cmd *mpt_cmd; union mrsas_evt_class_locale class_locale; MRSAS_REQUEST_DESCRIPTOR_UNION *req_desc; if (sc->adprecovery == MRSAS_HW_CRITICAL_ERROR) { device_printf(sc->mrsas_dev, "mrsas: Hardware critical error, returning FAIL.\n"); return FAIL; } mrsas_set_bit(MRSAS_FUSION_IN_RESET, &sc->reset_flags); sc->adprecovery = MRSAS_ADPRESET_SM_INFAULT; mrsas_disable_intr(sc); msleep(&sc->ocr_chan, &sc->sim_lock, PRIBIO, "mrsas_ocr", sc->mrsas_fw_fault_check_delay * hz); /* First try waiting for commands to complete */ if (mrsas_wait_for_outstanding(sc, reset_reason)) { mrsas_dprint(sc, MRSAS_OCR, "resetting adapter from %s.\n", __func__); /* Now return commands back to the CAM layer */ mtx_unlock(&sc->sim_lock); for (i = 0; i < sc->max_fw_cmds; i++) { mpt_cmd = sc->mpt_cmd_list[i]; if (mpt_cmd->peer_cmd) { mrsas_dprint(sc, MRSAS_OCR, "R1 FP command [%d] - (mpt_cmd) %p, (peer_cmd) %p\n", i, mpt_cmd, mpt_cmd->peer_cmd); } if (mpt_cmd->ccb_ptr) { if (mpt_cmd->callout_owner) { ccb = (union ccb *)(mpt_cmd->ccb_ptr); ccb->ccb_h.status = CAM_SCSI_BUS_RESET; mrsas_cmd_done(sc, mpt_cmd); } else { mpt_cmd->ccb_ptr = NULL; mrsas_release_mpt_cmd(mpt_cmd); } } } mrsas_atomic_set(&sc->fw_outstanding, 0); mtx_lock(&sc->sim_lock); status_reg = mrsas_read_reg_with_retries(sc, offsetof(mrsas_reg_set, outbound_scratch_pad)); abs_state = status_reg & MFI_STATE_MASK; reset_adapter = status_reg & MFI_RESET_ADAPTER; if (sc->disableOnlineCtrlReset || (abs_state == MFI_STATE_FAULT && !reset_adapter)) { /* Reset not supported, kill adapter */ mrsas_dprint(sc, MRSAS_OCR, "Reset not supported, killing adapter.\n"); mrsas_kill_hba(sc); retval = FAIL; goto out; } /* Now try to reset the chip */ for (i = 0; i < MRSAS_FUSION_MAX_RESET_TRIES; i++) { mrsas_write_reg(sc, offsetof(mrsas_reg_set, fusion_seq_offset), MPI2_WRSEQ_FLUSH_KEY_VALUE); mrsas_write_reg(sc, offsetof(mrsas_reg_set, fusion_seq_offset), MPI2_WRSEQ_1ST_KEY_VALUE); mrsas_write_reg(sc, offsetof(mrsas_reg_set, fusion_seq_offset), MPI2_WRSEQ_2ND_KEY_VALUE); mrsas_write_reg(sc, offsetof(mrsas_reg_set, fusion_seq_offset), MPI2_WRSEQ_3RD_KEY_VALUE); mrsas_write_reg(sc, offsetof(mrsas_reg_set, fusion_seq_offset), MPI2_WRSEQ_4TH_KEY_VALUE); mrsas_write_reg(sc, offsetof(mrsas_reg_set, fusion_seq_offset), MPI2_WRSEQ_5TH_KEY_VALUE); mrsas_write_reg(sc, offsetof(mrsas_reg_set, fusion_seq_offset), MPI2_WRSEQ_6TH_KEY_VALUE); /* Check that the diag write enable (DRWE) bit is on */ host_diag = mrsas_read_reg_with_retries(sc, offsetof(mrsas_reg_set, fusion_host_diag)); retry = 0; while (!(host_diag & HOST_DIAG_WRITE_ENABLE)) { DELAY(100 * 1000); host_diag = mrsas_read_reg_with_retries(sc, offsetof(mrsas_reg_set, fusion_host_diag)); if (retry++ == 100) { mrsas_dprint(sc, MRSAS_OCR, "Host diag unlock failed!\n"); break; } } if (!(host_diag & HOST_DIAG_WRITE_ENABLE)) continue; /* Send chip reset command */ mrsas_write_reg(sc, offsetof(mrsas_reg_set, fusion_host_diag), host_diag | HOST_DIAG_RESET_ADAPTER); DELAY(3000 * 1000); /* Make sure reset adapter bit is cleared */ host_diag = mrsas_read_reg_with_retries(sc, offsetof(mrsas_reg_set, fusion_host_diag)); retry = 0; while (host_diag & HOST_DIAG_RESET_ADAPTER) { DELAY(100 * 1000); host_diag = mrsas_read_reg_with_retries(sc, offsetof(mrsas_reg_set, fusion_host_diag)); if (retry++ == 1000) { mrsas_dprint(sc, MRSAS_OCR, "Diag reset adapter never cleared!\n"); break; } } if (host_diag & HOST_DIAG_RESET_ADAPTER) continue; abs_state = mrsas_read_reg_with_retries(sc, offsetof(mrsas_reg_set, outbound_scratch_pad)) & MFI_STATE_MASK; retry = 0; while ((abs_state <= MFI_STATE_FW_INIT) && (retry++ < 1000)) { DELAY(100 * 1000); abs_state = mrsas_read_reg_with_retries(sc, offsetof(mrsas_reg_set, outbound_scratch_pad)) & MFI_STATE_MASK; } if (abs_state <= MFI_STATE_FW_INIT) { mrsas_dprint(sc, MRSAS_OCR, "firmware state < MFI_STATE_FW_INIT," " state = 0x%x\n", abs_state); continue; } /* Wait for FW to become ready */ if (mrsas_transition_to_ready(sc, 1)) { mrsas_dprint(sc, MRSAS_OCR, "mrsas: Failed to transition controller to ready.\n"); continue; } mrsas_reset_reply_desc(sc); if (mrsas_ioc_init(sc)) { mrsas_dprint(sc, MRSAS_OCR, "mrsas_ioc_init() failed!\n"); continue; } for (j = 0; j < sc->max_fw_cmds; j++) { mpt_cmd = sc->mpt_cmd_list[j]; if (mpt_cmd->sync_cmd_idx != (u_int32_t)MRSAS_ULONG_MAX) { mfi_cmd = sc->mfi_cmd_list[mpt_cmd->sync_cmd_idx]; /* If not an IOCTL then release the command else re-fire */ if (!mfi_cmd->sync_cmd) { mrsas_release_mfi_cmd(mfi_cmd); } else { req_desc = mrsas_get_request_desc(sc, mfi_cmd->cmd_id.context.smid - 1); mrsas_dprint(sc, MRSAS_OCR, "Re-fire command DCMD opcode 0x%x index %d\n ", mfi_cmd->frame->dcmd.opcode, j); if (!req_desc) device_printf(sc->mrsas_dev, "Cannot build MPT cmd.\n"); else mrsas_fire_cmd(sc, req_desc->addr.u.low, req_desc->addr.u.high); } } } /* Reset load balance info */ memset(sc->load_balance_info, 0, sizeof(LD_LOAD_BALANCE_INFO) * MAX_LOGICAL_DRIVES_EXT); if (mrsas_get_ctrl_info(sc)) { mrsas_kill_hba(sc); retval = FAIL; goto out; } if (!mrsas_get_map_info(sc)) mrsas_sync_map_info(sc); megasas_setup_jbod_map(sc); if ((sc->is_ventura || sc->is_aero) && sc->streamDetectByLD) { for (j = 0; j < MAX_LOGICAL_DRIVES_EXT; ++j) { memset(sc->streamDetectByLD[i], 0, sizeof(LD_STREAM_DETECT)); sc->streamDetectByLD[i]->mruBitMap = MR_STREAM_BITMAP; } } mrsas_clear_bit(MRSAS_FUSION_IN_RESET, &sc->reset_flags); mrsas_enable_intr(sc); sc->adprecovery = MRSAS_HBA_OPERATIONAL; /* Register AEN with FW for last sequence number */ class_locale.members.reserved = 0; class_locale.members.locale = MR_EVT_LOCALE_ALL; class_locale.members.class = MR_EVT_CLASS_DEBUG; mtx_unlock(&sc->sim_lock); if (mrsas_register_aen(sc, sc->last_seq_num, class_locale.word)) { device_printf(sc->mrsas_dev, "ERROR: AEN registration FAILED from OCR !!! " "Further events from the controller cannot be notified." "Either there is some problem in the controller" "or the controller does not support AEN.\n" "Please contact to the SUPPORT TEAM if the problem persists\n"); } mtx_lock(&sc->sim_lock); /* Adapter reset completed successfully */ device_printf(sc->mrsas_dev, "Reset successful\n"); retval = SUCCESS; goto out; } /* Reset failed, kill the adapter */ device_printf(sc->mrsas_dev, "Reset failed, killing adapter.\n"); mrsas_kill_hba(sc); retval = FAIL; } else { mrsas_clear_bit(MRSAS_FUSION_IN_RESET, &sc->reset_flags); mrsas_enable_intr(sc); sc->adprecovery = MRSAS_HBA_OPERATIONAL; } out: mrsas_clear_bit(MRSAS_FUSION_IN_RESET, &sc->reset_flags); mrsas_dprint(sc, MRSAS_OCR, "Reset Exit with %d.\n", retval); return retval; } /* * mrsas_kill_hba: Kill HBA when OCR is not supported * input: Adapter Context. * * This function will kill HBA when OCR is not supported. */ void mrsas_kill_hba(struct mrsas_softc *sc) { sc->adprecovery = MRSAS_HW_CRITICAL_ERROR; DELAY(1000 * 1000); mrsas_dprint(sc, MRSAS_OCR, "%s\n", __func__); mrsas_write_reg(sc, offsetof(mrsas_reg_set, doorbell), MFI_STOP_ADP); /* Flush */ mrsas_read_reg(sc, offsetof(mrsas_reg_set, doorbell)); mrsas_complete_outstanding_ioctls(sc); } /** * mrsas_complete_outstanding_ioctls Complete pending IOCTLS after kill_hba * input: Controller softc * * Returns void */ void mrsas_complete_outstanding_ioctls(struct mrsas_softc *sc) { int i; struct mrsas_mpt_cmd *cmd_mpt; struct mrsas_mfi_cmd *cmd_mfi; u_int32_t count, MSIxIndex; count = sc->msix_vectors > 0 ? sc->msix_vectors : 1; for (i = 0; i < sc->max_fw_cmds; i++) { cmd_mpt = sc->mpt_cmd_list[i]; if (cmd_mpt->sync_cmd_idx != (u_int32_t)MRSAS_ULONG_MAX) { cmd_mfi = sc->mfi_cmd_list[cmd_mpt->sync_cmd_idx]; if (cmd_mfi->sync_cmd && cmd_mfi->frame->hdr.cmd != MFI_CMD_ABORT) { for (MSIxIndex = 0; MSIxIndex < count; MSIxIndex++) mrsas_complete_mptmfi_passthru(sc, cmd_mfi, cmd_mpt->io_request->RaidContext.raid_context.status); } } } } /* * mrsas_wait_for_outstanding: Wait for outstanding commands * input: Adapter Context. * * This function will wait for 180 seconds for outstanding commands to be * completed. */ int mrsas_wait_for_outstanding(struct mrsas_softc *sc, u_int8_t check_reason) { int i, outstanding, retval = 0; u_int32_t fw_state, count, MSIxIndex; for (i = 0; i < MRSAS_RESET_WAIT_TIME; i++) { if (sc->remove_in_progress) { mrsas_dprint(sc, MRSAS_OCR, "Driver remove or shutdown called.\n"); retval = 1; goto out; } /* Check if firmware is in fault state */ fw_state = mrsas_read_reg_with_retries(sc, offsetof(mrsas_reg_set, outbound_scratch_pad)) & MFI_STATE_MASK; if (fw_state == MFI_STATE_FAULT) { mrsas_dprint(sc, MRSAS_OCR, "Found FW in FAULT state, will reset adapter.\n"); count = sc->msix_vectors > 0 ? sc->msix_vectors : 1; mtx_unlock(&sc->sim_lock); for (MSIxIndex = 0; MSIxIndex < count; MSIxIndex++) mrsas_complete_cmd(sc, MSIxIndex); mtx_lock(&sc->sim_lock); retval = 1; goto out; } if (check_reason == MFI_DCMD_TIMEOUT_OCR) { mrsas_dprint(sc, MRSAS_OCR, "DCMD IO TIMEOUT detected, will reset adapter.\n"); retval = 1; goto out; } outstanding = mrsas_atomic_read(&sc->fw_outstanding); if (!outstanding) goto out; if (!(i % MRSAS_RESET_NOTICE_INTERVAL)) { mrsas_dprint(sc, MRSAS_OCR, "[%2d]waiting for %d " "commands to complete\n", i, outstanding); count = sc->msix_vectors > 0 ? sc->msix_vectors : 1; mtx_unlock(&sc->sim_lock); for (MSIxIndex = 0; MSIxIndex < count; MSIxIndex++) mrsas_complete_cmd(sc, MSIxIndex); mtx_lock(&sc->sim_lock); } DELAY(1000 * 1000); } if (mrsas_atomic_read(&sc->fw_outstanding)) { mrsas_dprint(sc, MRSAS_OCR, " pending commands remain after waiting," " will reset adapter.\n"); retval = 1; } out: return retval; } /* * mrsas_release_mfi_cmd: Return a cmd to free command pool * input: Command packet for return to free cmd pool * * This function returns the MFI & MPT command to the command list. */ void mrsas_release_mfi_cmd(struct mrsas_mfi_cmd *cmd_mfi) { struct mrsas_softc *sc = cmd_mfi->sc; struct mrsas_mpt_cmd *cmd_mpt; mtx_lock(&sc->mfi_cmd_pool_lock); /* * Release the mpt command (if at all it is allocated * associated with the mfi command */ if (cmd_mfi->cmd_id.context.smid) { mtx_lock(&sc->mpt_cmd_pool_lock); /* Get the mpt cmd from mfi cmd frame's smid value */ cmd_mpt = sc->mpt_cmd_list[cmd_mfi->cmd_id.context.smid-1]; cmd_mpt->flags = 0; cmd_mpt->sync_cmd_idx = (u_int32_t)MRSAS_ULONG_MAX; TAILQ_INSERT_HEAD(&(sc->mrsas_mpt_cmd_list_head), cmd_mpt, next); mtx_unlock(&sc->mpt_cmd_pool_lock); } /* Release the mfi command */ cmd_mfi->ccb_ptr = NULL; cmd_mfi->cmd_id.frame_count = 0; TAILQ_INSERT_HEAD(&(sc->mrsas_mfi_cmd_list_head), cmd_mfi, next); mtx_unlock(&sc->mfi_cmd_pool_lock); return; } /* * mrsas_get_controller_info: Returns FW's controller structure * input: Adapter soft state * Controller information structure * * Issues an internal command (DCMD) to get the FW's controller structure. This * information is mainly used to find out the maximum IO transfer per command * supported by the FW. */ static int mrsas_get_ctrl_info(struct mrsas_softc *sc) { int retcode = 0; u_int8_t do_ocr = 1; struct mrsas_mfi_cmd *cmd; struct mrsas_dcmd_frame *dcmd; cmd = mrsas_get_mfi_cmd(sc); if (!cmd) { device_printf(sc->mrsas_dev, "Failed to get a free cmd\n"); return -ENOMEM; } dcmd = &cmd->frame->dcmd; if (mrsas_alloc_ctlr_info_cmd(sc) != SUCCESS) { device_printf(sc->mrsas_dev, "Cannot allocate get ctlr info cmd\n"); mrsas_release_mfi_cmd(cmd); return -ENOMEM; } memset(dcmd->mbox.b, 0, MFI_MBOX_SIZE); dcmd->cmd = MFI_CMD_DCMD; dcmd->cmd_status = 0xFF; dcmd->sge_count = 1; dcmd->flags = MFI_FRAME_DIR_READ; dcmd->timeout = 0; dcmd->pad_0 = 0; dcmd->data_xfer_len = sizeof(struct mrsas_ctrl_info); dcmd->opcode = MR_DCMD_CTRL_GET_INFO; dcmd->sgl.sge32[0].phys_addr = sc->ctlr_info_phys_addr; dcmd->sgl.sge32[0].length = sizeof(struct mrsas_ctrl_info); if (!sc->mask_interrupts) retcode = mrsas_issue_blocked_cmd(sc, cmd); else retcode = mrsas_issue_polled(sc, cmd); if (retcode == ETIMEDOUT) goto dcmd_timeout; else memcpy(sc->ctrl_info, sc->ctlr_info_mem, sizeof(struct mrsas_ctrl_info)); do_ocr = 0; mrsas_update_ext_vd_details(sc); sc->use_seqnum_jbod_fp = sc->ctrl_info->adapterOperations3.useSeqNumJbodFP; sc->support_morethan256jbod = sc->ctrl_info->adapterOperations4.supportPdMapTargetId; sc->disableOnlineCtrlReset = sc->ctrl_info->properties.OnOffProperties.disableOnlineCtrlReset; dcmd_timeout: mrsas_free_ctlr_info_cmd(sc); if (do_ocr) sc->do_timedout_reset = MFI_DCMD_TIMEOUT_OCR; if (!sc->mask_interrupts) mrsas_release_mfi_cmd(cmd); return (retcode); } /* * mrsas_update_ext_vd_details : Update details w.r.t Extended VD * input: * sc - Controller's softc */ static void mrsas_update_ext_vd_details(struct mrsas_softc *sc) { u_int32_t ventura_map_sz = 0; sc->max256vdSupport = sc->ctrl_info->adapterOperations3.supportMaxExtLDs; /* Below is additional check to address future FW enhancement */ if (sc->ctrl_info->max_lds > 64) sc->max256vdSupport = 1; sc->drv_supported_vd_count = MRSAS_MAX_LD_CHANNELS * MRSAS_MAX_DEV_PER_CHANNEL; sc->drv_supported_pd_count = MRSAS_MAX_PD_CHANNELS * MRSAS_MAX_DEV_PER_CHANNEL; if (sc->max256vdSupport) { sc->fw_supported_vd_count = MAX_LOGICAL_DRIVES_EXT; sc->fw_supported_pd_count = MAX_PHYSICAL_DEVICES; } else { sc->fw_supported_vd_count = MAX_LOGICAL_DRIVES; sc->fw_supported_pd_count = MAX_PHYSICAL_DEVICES; } if (sc->maxRaidMapSize) { ventura_map_sz = sc->maxRaidMapSize * MR_MIN_MAP_SIZE; sc->current_map_sz = ventura_map_sz; sc->max_map_sz = ventura_map_sz; } else { sc->old_map_sz = sizeof(MR_FW_RAID_MAP) + (sizeof(MR_LD_SPAN_MAP) * (sc->fw_supported_vd_count - 1)); sc->new_map_sz = sizeof(MR_FW_RAID_MAP_EXT); sc->max_map_sz = max(sc->old_map_sz, sc->new_map_sz); if (sc->max256vdSupport) sc->current_map_sz = sc->new_map_sz; else sc->current_map_sz = sc->old_map_sz; } sc->drv_map_sz = sizeof(MR_DRV_RAID_MAP_ALL); #if VD_EXT_DEBUG device_printf(sc->mrsas_dev, "sc->maxRaidMapSize 0x%x \n", sc->maxRaidMapSize); device_printf(sc->mrsas_dev, "new_map_sz = 0x%x, old_map_sz = 0x%x, " "ventura_map_sz = 0x%x, current_map_sz = 0x%x " "fusion->drv_map_sz =0x%x, size of driver raid map 0x%lx \n", sc->new_map_sz, sc->old_map_sz, ventura_map_sz, sc->current_map_sz, sc->drv_map_sz, sizeof(MR_DRV_RAID_MAP_ALL)); #endif } /* * mrsas_alloc_ctlr_info_cmd: Allocates memory for controller info command * input: Adapter soft state * * Allocates DMAable memory for the controller info internal command. */ int mrsas_alloc_ctlr_info_cmd(struct mrsas_softc *sc) { int ctlr_info_size; /* Allocate get controller info command */ ctlr_info_size = sizeof(struct mrsas_ctrl_info); if (bus_dma_tag_create(sc->mrsas_parent_tag, 1, 0, BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL, ctlr_info_size, 1, ctlr_info_size, BUS_DMA_ALLOCNOW, NULL, NULL, &sc->ctlr_info_tag)) { device_printf(sc->mrsas_dev, "Cannot allocate ctlr info tag\n"); return (ENOMEM); } if (bus_dmamem_alloc(sc->ctlr_info_tag, (void **)&sc->ctlr_info_mem, BUS_DMA_NOWAIT, &sc->ctlr_info_dmamap)) { device_printf(sc->mrsas_dev, "Cannot allocate ctlr info cmd mem\n"); return (ENOMEM); } if (bus_dmamap_load(sc->ctlr_info_tag, sc->ctlr_info_dmamap, sc->ctlr_info_mem, ctlr_info_size, mrsas_addr_cb, &sc->ctlr_info_phys_addr, BUS_DMA_NOWAIT)) { device_printf(sc->mrsas_dev, "Cannot load ctlr info cmd mem\n"); return (ENOMEM); } memset(sc->ctlr_info_mem, 0, ctlr_info_size); return (0); } /* * mrsas_free_ctlr_info_cmd: Free memory for controller info command * input: Adapter soft state * * Deallocates memory of the get controller info cmd. */ void mrsas_free_ctlr_info_cmd(struct mrsas_softc *sc) { if (sc->ctlr_info_phys_addr) bus_dmamap_unload(sc->ctlr_info_tag, sc->ctlr_info_dmamap); if (sc->ctlr_info_mem != NULL) bus_dmamem_free(sc->ctlr_info_tag, sc->ctlr_info_mem, sc->ctlr_info_dmamap); if (sc->ctlr_info_tag != NULL) bus_dma_tag_destroy(sc->ctlr_info_tag); } /* * mrsas_issue_polled: Issues a polling command * inputs: Adapter soft state * Command packet to be issued * * This function is for posting of internal commands to Firmware. MFI requires * the cmd_status to be set to 0xFF before posting. The maximun wait time of * the poll response timer is 180 seconds. */ int mrsas_issue_polled(struct mrsas_softc *sc, struct mrsas_mfi_cmd *cmd) { struct mrsas_header *frame_hdr = &cmd->frame->hdr; u_int8_t max_wait = MRSAS_INTERNAL_CMD_WAIT_TIME; int i, retcode = SUCCESS; frame_hdr->cmd_status = 0xFF; frame_hdr->flags |= MFI_FRAME_DONT_POST_IN_REPLY_QUEUE; /* Issue the frame using inbound queue port */ if (mrsas_issue_dcmd(sc, cmd)) { device_printf(sc->mrsas_dev, "Cannot issue DCMD internal command.\n"); return (1); } /* * Poll response timer to wait for Firmware response. While this * timer with the DELAY call could block CPU, the time interval for * this is only 1 millisecond. */ if (frame_hdr->cmd_status == 0xFF) { for (i = 0; i < (max_wait * 1000); i++) { if (frame_hdr->cmd_status == 0xFF) DELAY(1000); else break; } } if (frame_hdr->cmd_status == 0xFF) { device_printf(sc->mrsas_dev, "DCMD timed out after %d " "seconds from %s\n", max_wait, __func__); device_printf(sc->mrsas_dev, "DCMD opcode 0x%X\n", cmd->frame->dcmd.opcode); retcode = ETIMEDOUT; } return (retcode); } /* * mrsas_issue_dcmd: Issues a MFI Pass thru cmd * input: Adapter soft state mfi cmd pointer * * This function is called by mrsas_issued_blocked_cmd() and * mrsas_issued_polled(), to build the MPT command and then fire the command * to Firmware. */ int mrsas_issue_dcmd(struct mrsas_softc *sc, struct mrsas_mfi_cmd *cmd) { MRSAS_REQUEST_DESCRIPTOR_UNION *req_desc; req_desc = mrsas_build_mpt_cmd(sc, cmd); if (!req_desc) { device_printf(sc->mrsas_dev, "Cannot build MPT cmd.\n"); return (1); } mrsas_fire_cmd(sc, req_desc->addr.u.low, req_desc->addr.u.high); return (0); } /* * mrsas_build_mpt_cmd: Calls helper function to build Passthru cmd * input: Adapter soft state mfi cmd to build * * This function is called by mrsas_issue_cmd() to build the MPT-MFI passthru * command and prepares the MPT command to send to Firmware. */ MRSAS_REQUEST_DESCRIPTOR_UNION * mrsas_build_mpt_cmd(struct mrsas_softc *sc, struct mrsas_mfi_cmd *cmd) { MRSAS_REQUEST_DESCRIPTOR_UNION *req_desc; u_int16_t index; if (mrsas_build_mptmfi_passthru(sc, cmd)) { device_printf(sc->mrsas_dev, "Cannot build MPT-MFI passthru cmd.\n"); return NULL; } index = cmd->cmd_id.context.smid; req_desc = mrsas_get_request_desc(sc, index - 1); if (!req_desc) return NULL; req_desc->addr.Words = 0; req_desc->SCSIIO.RequestFlags = (MPI2_REQ_DESCRIPT_FLAGS_SCSI_IO << MRSAS_REQ_DESCRIPT_FLAGS_TYPE_SHIFT); req_desc->SCSIIO.SMID = index; return (req_desc); } /* * mrsas_build_mptmfi_passthru: Builds a MPT MFI Passthru command * input: Adapter soft state mfi cmd pointer * * The MPT command and the io_request are setup as a passthru command. The SGE * chain address is set to frame_phys_addr of the MFI command. */ u_int8_t mrsas_build_mptmfi_passthru(struct mrsas_softc *sc, struct mrsas_mfi_cmd *mfi_cmd) { MPI25_IEEE_SGE_CHAIN64 *mpi25_ieee_chain; PTR_MRSAS_RAID_SCSI_IO_REQUEST io_req; struct mrsas_mpt_cmd *mpt_cmd; struct mrsas_header *frame_hdr = &mfi_cmd->frame->hdr; mpt_cmd = mrsas_get_mpt_cmd(sc); if (!mpt_cmd) return (1); /* Save the smid. To be used for returning the cmd */ mfi_cmd->cmd_id.context.smid = mpt_cmd->index; mpt_cmd->sync_cmd_idx = mfi_cmd->index; /* * For cmds where the flag is set, store the flag and check on * completion. For cmds with this flag, don't call * mrsas_complete_cmd. */ if (frame_hdr->flags & MFI_FRAME_DONT_POST_IN_REPLY_QUEUE) mpt_cmd->flags = MFI_FRAME_DONT_POST_IN_REPLY_QUEUE; io_req = mpt_cmd->io_request; if (sc->mrsas_gen3_ctrl || sc->is_ventura || sc->is_aero) { pMpi25IeeeSgeChain64_t sgl_ptr_end = (pMpi25IeeeSgeChain64_t)&io_req->SGL; sgl_ptr_end += sc->max_sge_in_main_msg - 1; sgl_ptr_end->Flags = 0; } mpi25_ieee_chain = (MPI25_IEEE_SGE_CHAIN64 *) & io_req->SGL.IeeeChain; io_req->Function = MRSAS_MPI2_FUNCTION_PASSTHRU_IO_REQUEST; io_req->SGLOffset0 = offsetof(MRSAS_RAID_SCSI_IO_REQUEST, SGL) / 4; io_req->ChainOffset = sc->chain_offset_mfi_pthru; mpi25_ieee_chain->Address = mfi_cmd->frame_phys_addr; mpi25_ieee_chain->Flags = IEEE_SGE_FLAGS_CHAIN_ELEMENT | MPI2_IEEE_SGE_FLAGS_IOCPLBNTA_ADDR; mpi25_ieee_chain->Length = sc->max_chain_frame_sz; return (0); } /* * mrsas_issue_blocked_cmd: Synchronous wrapper around regular FW cmds * input: Adapter soft state Command to be issued * * This function waits on an event for the command to be returned from the ISR. * Max wait time is MRSAS_INTERNAL_CMD_WAIT_TIME secs. Used for issuing * internal and ioctl commands. */ int mrsas_issue_blocked_cmd(struct mrsas_softc *sc, struct mrsas_mfi_cmd *cmd) { u_int8_t max_wait = MRSAS_INTERNAL_CMD_WAIT_TIME; unsigned long total_time = 0; int retcode = SUCCESS; /* Initialize cmd_status */ cmd->cmd_status = 0xFF; /* Build MPT-MFI command for issue to FW */ if (mrsas_issue_dcmd(sc, cmd)) { device_printf(sc->mrsas_dev, "Cannot issue DCMD internal command.\n"); return (1); } sc->chan = (void *)&cmd; while (1) { if (cmd->cmd_status == 0xFF) { tsleep((void *)&sc->chan, 0, "mrsas_sleep", hz); } else break; if (!cmd->sync_cmd) { /* cmd->sync will be set for an IOCTL * command */ total_time++; if (total_time >= max_wait) { device_printf(sc->mrsas_dev, "Internal command timed out after %d seconds.\n", max_wait); retcode = 1; break; } } } if (cmd->cmd_status == 0xFF) { device_printf(sc->mrsas_dev, "DCMD timed out after %d " "seconds from %s\n", max_wait, __func__); device_printf(sc->mrsas_dev, "DCMD opcode 0x%X\n", cmd->frame->dcmd.opcode); retcode = ETIMEDOUT; } return (retcode); } /* * mrsas_complete_mptmfi_passthru: Completes a command * input: @sc: Adapter soft state * @cmd: Command to be completed * @status: cmd completion status * * This function is called from mrsas_complete_cmd() after an interrupt is * received from Firmware, and io_request->Function is * MRSAS_MPI2_FUNCTION_PASSTHRU_IO_REQUEST. */ void mrsas_complete_mptmfi_passthru(struct mrsas_softc *sc, struct mrsas_mfi_cmd *cmd, u_int8_t status) { struct mrsas_header *hdr = &cmd->frame->hdr; u_int8_t cmd_status = cmd->frame->hdr.cmd_status; /* Reset the retry counter for future re-tries */ cmd->retry_for_fw_reset = 0; if (cmd->ccb_ptr) cmd->ccb_ptr = NULL; switch (hdr->cmd) { case MFI_CMD_INVALID: device_printf(sc->mrsas_dev, "MFI_CMD_INVALID command.\n"); break; case MFI_CMD_PD_SCSI_IO: case MFI_CMD_LD_SCSI_IO: /* * MFI_CMD_PD_SCSI_IO and MFI_CMD_LD_SCSI_IO could have been * issued either through an IO path or an IOCTL path. If it * was via IOCTL, we will send it to internal completion. */ if (cmd->sync_cmd) { cmd->sync_cmd = 0; mrsas_wakeup(sc, cmd); break; } case MFI_CMD_SMP: case MFI_CMD_STP: case MFI_CMD_DCMD: /* Check for LD map update */ if ((cmd->frame->dcmd.opcode == MR_DCMD_LD_MAP_GET_INFO) && (cmd->frame->dcmd.mbox.b[1] == 1)) { sc->fast_path_io = 0; mtx_lock(&sc->raidmap_lock); sc->map_update_cmd = NULL; if (cmd_status != 0) { if (cmd_status != MFI_STAT_NOT_FOUND) device_printf(sc->mrsas_dev, "map sync failed, status=%x\n", cmd_status); else { mrsas_release_mfi_cmd(cmd); mtx_unlock(&sc->raidmap_lock); break; } } else sc->map_id++; mrsas_release_mfi_cmd(cmd); if (MR_ValidateMapInfo(sc)) sc->fast_path_io = 0; else sc->fast_path_io = 1; mrsas_sync_map_info(sc); mtx_unlock(&sc->raidmap_lock); break; } if (cmd->frame->dcmd.opcode == MR_DCMD_CTRL_EVENT_GET_INFO || cmd->frame->dcmd.opcode == MR_DCMD_CTRL_EVENT_GET) { sc->mrsas_aen_triggered = 0; } /* FW has an updated PD sequence */ if ((cmd->frame->dcmd.opcode == MR_DCMD_SYSTEM_PD_MAP_GET_INFO) && (cmd->frame->dcmd.mbox.b[0] == 1)) { mtx_lock(&sc->raidmap_lock); sc->jbod_seq_cmd = NULL; mrsas_release_mfi_cmd(cmd); if (cmd_status == MFI_STAT_OK) { sc->pd_seq_map_id++; /* Re-register a pd sync seq num cmd */ if (megasas_sync_pd_seq_num(sc, true)) sc->use_seqnum_jbod_fp = 0; } else { sc->use_seqnum_jbod_fp = 0; device_printf(sc->mrsas_dev, "Jbod map sync failed, status=%x\n", cmd_status); } mtx_unlock(&sc->raidmap_lock); break; } /* See if got an event notification */ if (cmd->frame->dcmd.opcode == MR_DCMD_CTRL_EVENT_WAIT) mrsas_complete_aen(sc, cmd); else mrsas_wakeup(sc, cmd); break; case MFI_CMD_ABORT: /* Command issued to abort another cmd return */ mrsas_complete_abort(sc, cmd); break; default: device_printf(sc->mrsas_dev, "Unknown command completed! [0x%X]\n", hdr->cmd); break; } } /* * mrsas_wakeup: Completes an internal command * input: Adapter soft state * Command to be completed * * In mrsas_issue_blocked_cmd(), after a command is issued to Firmware, a wait * timer is started. This function is called from * mrsas_complete_mptmfi_passthru() as it completes the command, to wake up * from the command wait. */ void mrsas_wakeup(struct mrsas_softc *sc, struct mrsas_mfi_cmd *cmd) { cmd->cmd_status = cmd->frame->io.cmd_status; if (cmd->cmd_status == 0xFF) cmd->cmd_status = 0; sc->chan = (void *)&cmd; wakeup_one((void *)&sc->chan); return; } /* * mrsas_shutdown_ctlr: Instructs FW to shutdown the controller input: * Adapter soft state Shutdown/Hibernate * * This function issues a DCMD internal command to Firmware to initiate shutdown * of the controller. */ static void mrsas_shutdown_ctlr(struct mrsas_softc *sc, u_int32_t opcode) { struct mrsas_mfi_cmd *cmd; struct mrsas_dcmd_frame *dcmd; if (sc->adprecovery == MRSAS_HW_CRITICAL_ERROR) return; cmd = mrsas_get_mfi_cmd(sc); if (!cmd) { device_printf(sc->mrsas_dev, "Cannot allocate for shutdown cmd.\n"); return; } if (sc->aen_cmd) mrsas_issue_blocked_abort_cmd(sc, sc->aen_cmd); if (sc->map_update_cmd) mrsas_issue_blocked_abort_cmd(sc, sc->map_update_cmd); if (sc->jbod_seq_cmd) mrsas_issue_blocked_abort_cmd(sc, sc->jbod_seq_cmd); dcmd = &cmd->frame->dcmd; memset(dcmd->mbox.b, 0, MFI_MBOX_SIZE); dcmd->cmd = MFI_CMD_DCMD; dcmd->cmd_status = 0x0; dcmd->sge_count = 0; dcmd->flags = MFI_FRAME_DIR_NONE; dcmd->timeout = 0; dcmd->pad_0 = 0; dcmd->data_xfer_len = 0; dcmd->opcode = opcode; device_printf(sc->mrsas_dev, "Preparing to shut down controller.\n"); mrsas_issue_blocked_cmd(sc, cmd); mrsas_release_mfi_cmd(cmd); return; } /* * mrsas_flush_cache: Requests FW to flush all its caches input: * Adapter soft state * * This function is issues a DCMD internal command to Firmware to initiate * flushing of all caches. */ static void mrsas_flush_cache(struct mrsas_softc *sc) { struct mrsas_mfi_cmd *cmd; struct mrsas_dcmd_frame *dcmd; if (sc->adprecovery == MRSAS_HW_CRITICAL_ERROR) return; cmd = mrsas_get_mfi_cmd(sc); if (!cmd) { device_printf(sc->mrsas_dev, "Cannot allocate for flush cache cmd.\n"); return; } dcmd = &cmd->frame->dcmd; memset(dcmd->mbox.b, 0, MFI_MBOX_SIZE); dcmd->cmd = MFI_CMD_DCMD; dcmd->cmd_status = 0x0; dcmd->sge_count = 0; dcmd->flags = MFI_FRAME_DIR_NONE; dcmd->timeout = 0; dcmd->pad_0 = 0; dcmd->data_xfer_len = 0; dcmd->opcode = MR_DCMD_CTRL_CACHE_FLUSH; dcmd->mbox.b[0] = MR_FLUSH_CTRL_CACHE | MR_FLUSH_DISK_CACHE; mrsas_issue_blocked_cmd(sc, cmd); mrsas_release_mfi_cmd(cmd); return; } int megasas_sync_pd_seq_num(struct mrsas_softc *sc, boolean_t pend) { int retcode = 0; u_int8_t do_ocr = 1; struct mrsas_mfi_cmd *cmd; struct mrsas_dcmd_frame *dcmd; uint32_t pd_seq_map_sz; struct MR_PD_CFG_SEQ_NUM_SYNC *pd_sync; bus_addr_t pd_seq_h; pd_seq_map_sz = sizeof(struct MR_PD_CFG_SEQ_NUM_SYNC) + (sizeof(struct MR_PD_CFG_SEQ) * (MAX_PHYSICAL_DEVICES - 1)); cmd = mrsas_get_mfi_cmd(sc); if (!cmd) { device_printf(sc->mrsas_dev, "Cannot alloc for ld map info cmd.\n"); return 1; } dcmd = &cmd->frame->dcmd; pd_sync = (void *)sc->jbodmap_mem[(sc->pd_seq_map_id & 1)]; pd_seq_h = sc->jbodmap_phys_addr[(sc->pd_seq_map_id & 1)]; if (!pd_sync) { device_printf(sc->mrsas_dev, "Failed to alloc mem for jbod map info.\n"); mrsas_release_mfi_cmd(cmd); return (ENOMEM); } memset(pd_sync, 0, pd_seq_map_sz); memset(dcmd->mbox.b, 0, MFI_MBOX_SIZE); dcmd->cmd = MFI_CMD_DCMD; dcmd->cmd_status = 0xFF; dcmd->sge_count = 1; dcmd->timeout = 0; dcmd->pad_0 = 0; dcmd->data_xfer_len = (pd_seq_map_sz); dcmd->opcode = (MR_DCMD_SYSTEM_PD_MAP_GET_INFO); dcmd->sgl.sge32[0].phys_addr = (pd_seq_h); dcmd->sgl.sge32[0].length = (pd_seq_map_sz); if (pend) { dcmd->mbox.b[0] = MRSAS_DCMD_MBOX_PEND_FLAG; dcmd->flags = (MFI_FRAME_DIR_WRITE); sc->jbod_seq_cmd = cmd; if (mrsas_issue_dcmd(sc, cmd)) { device_printf(sc->mrsas_dev, "Fail to send sync map info command.\n"); return 1; } else return 0; } else dcmd->flags = MFI_FRAME_DIR_READ; retcode = mrsas_issue_polled(sc, cmd); if (retcode == ETIMEDOUT) goto dcmd_timeout; if (pd_sync->count > MAX_PHYSICAL_DEVICES) { device_printf(sc->mrsas_dev, "driver supports max %d JBOD, but FW reports %d\n", MAX_PHYSICAL_DEVICES, pd_sync->count); retcode = -EINVAL; } if (!retcode) sc->pd_seq_map_id++; do_ocr = 0; dcmd_timeout: if (do_ocr) sc->do_timedout_reset = MFI_DCMD_TIMEOUT_OCR; return (retcode); } /* * mrsas_get_map_info: Load and validate RAID map input: * Adapter instance soft state * * This function calls mrsas_get_ld_map_info() and MR_ValidateMapInfo() to load * and validate RAID map. It returns 0 if successful, 1 other- wise. */ static int mrsas_get_map_info(struct mrsas_softc *sc) { uint8_t retcode = 0; sc->fast_path_io = 0; if (!mrsas_get_ld_map_info(sc)) { retcode = MR_ValidateMapInfo(sc); if (retcode == 0) { sc->fast_path_io = 1; return 0; } } return 1; } /* * mrsas_get_ld_map_info: Get FW's ld_map structure input: * Adapter instance soft state * * Issues an internal command (DCMD) to get the FW's controller PD list * structure. */ static int mrsas_get_ld_map_info(struct mrsas_softc *sc) { int retcode = 0; struct mrsas_mfi_cmd *cmd; struct mrsas_dcmd_frame *dcmd; void *map; bus_addr_t map_phys_addr = 0; cmd = mrsas_get_mfi_cmd(sc); if (!cmd) { device_printf(sc->mrsas_dev, "Cannot alloc for ld map info cmd.\n"); return 1; } dcmd = &cmd->frame->dcmd; map = (void *)sc->raidmap_mem[(sc->map_id & 1)]; map_phys_addr = sc->raidmap_phys_addr[(sc->map_id & 1)]; if (!map) { device_printf(sc->mrsas_dev, "Failed to alloc mem for ld map info.\n"); mrsas_release_mfi_cmd(cmd); return (ENOMEM); } memset(map, 0, sizeof(sc->max_map_sz)); memset(dcmd->mbox.b, 0, MFI_MBOX_SIZE); dcmd->cmd = MFI_CMD_DCMD; dcmd->cmd_status = 0xFF; dcmd->sge_count = 1; dcmd->flags = MFI_FRAME_DIR_READ; dcmd->timeout = 0; dcmd->pad_0 = 0; dcmd->data_xfer_len = sc->current_map_sz; dcmd->opcode = MR_DCMD_LD_MAP_GET_INFO; dcmd->sgl.sge32[0].phys_addr = map_phys_addr; dcmd->sgl.sge32[0].length = sc->current_map_sz; retcode = mrsas_issue_polled(sc, cmd); if (retcode == ETIMEDOUT) sc->do_timedout_reset = MFI_DCMD_TIMEOUT_OCR; return (retcode); } /* * mrsas_sync_map_info: Get FW's ld_map structure input: * Adapter instance soft state * * Issues an internal command (DCMD) to get the FW's controller PD list * structure. */ static int mrsas_sync_map_info(struct mrsas_softc *sc) { int retcode = 0, i; struct mrsas_mfi_cmd *cmd; struct mrsas_dcmd_frame *dcmd; uint32_t size_sync_info, num_lds; MR_LD_TARGET_SYNC *target_map = NULL; MR_DRV_RAID_MAP_ALL *map; MR_LD_RAID *raid; MR_LD_TARGET_SYNC *ld_sync; bus_addr_t map_phys_addr = 0; cmd = mrsas_get_mfi_cmd(sc); if (!cmd) { device_printf(sc->mrsas_dev, "Cannot alloc for sync map info cmd\n"); return ENOMEM; } map = sc->ld_drv_map[sc->map_id & 1]; num_lds = map->raidMap.ldCount; dcmd = &cmd->frame->dcmd; size_sync_info = sizeof(MR_LD_TARGET_SYNC) * num_lds; memset(dcmd->mbox.b, 0, MFI_MBOX_SIZE); target_map = (MR_LD_TARGET_SYNC *) sc->raidmap_mem[(sc->map_id - 1) & 1]; memset(target_map, 0, sc->max_map_sz); map_phys_addr = sc->raidmap_phys_addr[(sc->map_id - 1) & 1]; ld_sync = (MR_LD_TARGET_SYNC *) target_map; for (i = 0; i < num_lds; i++, ld_sync++) { raid = MR_LdRaidGet(i, map); ld_sync->targetId = MR_GetLDTgtId(i, map); ld_sync->seqNum = raid->seqNum; } dcmd->cmd = MFI_CMD_DCMD; dcmd->cmd_status = 0xFF; dcmd->sge_count = 1; dcmd->flags = MFI_FRAME_DIR_WRITE; dcmd->timeout = 0; dcmd->pad_0 = 0; dcmd->data_xfer_len = sc->current_map_sz; dcmd->mbox.b[0] = num_lds; dcmd->mbox.b[1] = MRSAS_DCMD_MBOX_PEND_FLAG; dcmd->opcode = MR_DCMD_LD_MAP_GET_INFO; dcmd->sgl.sge32[0].phys_addr = map_phys_addr; dcmd->sgl.sge32[0].length = sc->current_map_sz; sc->map_update_cmd = cmd; if (mrsas_issue_dcmd(sc, cmd)) { device_printf(sc->mrsas_dev, "Fail to send sync map info command.\n"); return (1); } return (retcode); } /* Input: dcmd.opcode - MR_DCMD_PD_GET_INFO * dcmd.mbox.s[0] - deviceId for this physical drive * dcmd.sge IN - ptr to returned MR_PD_INFO structure * Desc: Firmware return the physical drive info structure * */ static void mrsas_get_pd_info(struct mrsas_softc *sc, u_int16_t device_id) { int retcode; u_int8_t do_ocr = 1; struct mrsas_mfi_cmd *cmd; struct mrsas_dcmd_frame *dcmd; cmd = mrsas_get_mfi_cmd(sc); if (!cmd) { device_printf(sc->mrsas_dev, "Cannot alloc for get PD info cmd\n"); return; } dcmd = &cmd->frame->dcmd; memset(sc->pd_info_mem, 0, sizeof(struct mrsas_pd_info)); memset(dcmd->mbox.b, 0, MFI_MBOX_SIZE); dcmd->mbox.s[0] = device_id; dcmd->cmd = MFI_CMD_DCMD; dcmd->cmd_status = 0xFF; dcmd->sge_count = 1; dcmd->flags = MFI_FRAME_DIR_READ; dcmd->timeout = 0; dcmd->pad_0 = 0; dcmd->data_xfer_len = sizeof(struct mrsas_pd_info); dcmd->opcode = MR_DCMD_PD_GET_INFO; dcmd->sgl.sge32[0].phys_addr = (u_int32_t)sc->pd_info_phys_addr; dcmd->sgl.sge32[0].length = sizeof(struct mrsas_pd_info); if (!sc->mask_interrupts) retcode = mrsas_issue_blocked_cmd(sc, cmd); else retcode = mrsas_issue_polled(sc, cmd); if (retcode == ETIMEDOUT) goto dcmd_timeout; sc->target_list[device_id].interface_type = sc->pd_info_mem->state.ddf.pdType.intf; do_ocr = 0; dcmd_timeout: if (do_ocr) sc->do_timedout_reset = MFI_DCMD_TIMEOUT_OCR; if (!sc->mask_interrupts) mrsas_release_mfi_cmd(cmd); } /* * mrsas_add_target: Add target ID of system PD/VD to driver's data structure. * sc: Adapter's soft state * target_id: Unique target id per controller(managed by driver) * for system PDs- target ID ranges from 0 to (MRSAS_MAX_PD - 1) * for VDs- target ID ranges from MRSAS_MAX_PD to MRSAS_MAX_TM_TARGETS * return: void * Descripton: This function will be called whenever system PD or VD is created. */ static void mrsas_add_target(struct mrsas_softc *sc, u_int16_t target_id) { sc->target_list[target_id].target_id = target_id; device_printf(sc->mrsas_dev, "%s created target ID: 0x%x\n", (target_id < MRSAS_MAX_PD ? "System PD" : "VD"), (target_id < MRSAS_MAX_PD ? target_id : (target_id - MRSAS_MAX_PD))); /* * If interrupts are enabled, then only fire DCMD to get pd_info * for system PDs */ if (!sc->mask_interrupts && sc->pd_info_mem && (target_id < MRSAS_MAX_PD)) mrsas_get_pd_info(sc, target_id); } /* * mrsas_remove_target: Remove target ID of system PD/VD from driver's data structure. * sc: Adapter's soft state * target_id: Unique target id per controller(managed by driver) * for system PDs- target ID ranges from 0 to (MRSAS_MAX_PD - 1) * for VDs- target ID ranges from MRSAS_MAX_PD to MRSAS_MAX_TM_TARGETS * return: void * Descripton: This function will be called whenever system PD or VD is deleted */ static void mrsas_remove_target(struct mrsas_softc *sc, u_int16_t target_id) { sc->target_list[target_id].target_id = 0xffff; device_printf(sc->mrsas_dev, "%s deleted target ID: 0x%x\n", (target_id < MRSAS_MAX_PD ? "System PD" : "VD"), (target_id < MRSAS_MAX_PD ? target_id : (target_id - MRSAS_MAX_PD))); } /* * mrsas_get_pd_list: Returns FW's PD list structure input: * Adapter soft state * * Issues an internal command (DCMD) to get the FW's controller PD list * structure. This information is mainly used to find out about system * supported by Firmware. */ static int mrsas_get_pd_list(struct mrsas_softc *sc) { int retcode = 0, pd_index = 0, pd_count = 0, pd_list_size; u_int8_t do_ocr = 1; struct mrsas_mfi_cmd *cmd; struct mrsas_dcmd_frame *dcmd; struct MR_PD_LIST *pd_list_mem; struct MR_PD_ADDRESS *pd_addr; bus_addr_t pd_list_phys_addr = 0; struct mrsas_tmp_dcmd *tcmd; cmd = mrsas_get_mfi_cmd(sc); if (!cmd) { device_printf(sc->mrsas_dev, "Cannot alloc for get PD list cmd\n"); return 1; } dcmd = &cmd->frame->dcmd; tcmd = malloc(sizeof(struct mrsas_tmp_dcmd), M_MRSAS, M_NOWAIT); pd_list_size = MRSAS_MAX_PD * sizeof(struct MR_PD_LIST); if (mrsas_alloc_tmp_dcmd(sc, tcmd, pd_list_size) != SUCCESS) { device_printf(sc->mrsas_dev, "Cannot alloc dmamap for get PD list cmd\n"); mrsas_release_mfi_cmd(cmd); mrsas_free_tmp_dcmd(tcmd); free(tcmd, M_MRSAS); return (ENOMEM); } else { pd_list_mem = tcmd->tmp_dcmd_mem; pd_list_phys_addr = tcmd->tmp_dcmd_phys_addr; } memset(dcmd->mbox.b, 0, MFI_MBOX_SIZE); dcmd->mbox.b[0] = MR_PD_QUERY_TYPE_EXPOSED_TO_HOST; dcmd->mbox.b[1] = 0; dcmd->cmd = MFI_CMD_DCMD; dcmd->cmd_status = 0xFF; dcmd->sge_count = 1; dcmd->flags = MFI_FRAME_DIR_READ; dcmd->timeout = 0; dcmd->pad_0 = 0; dcmd->data_xfer_len = MRSAS_MAX_PD * sizeof(struct MR_PD_LIST); dcmd->opcode = MR_DCMD_PD_LIST_QUERY; dcmd->sgl.sge32[0].phys_addr = pd_list_phys_addr; dcmd->sgl.sge32[0].length = MRSAS_MAX_PD * sizeof(struct MR_PD_LIST); if (!sc->mask_interrupts) retcode = mrsas_issue_blocked_cmd(sc, cmd); else retcode = mrsas_issue_polled(sc, cmd); if (retcode == ETIMEDOUT) goto dcmd_timeout; /* Get the instance PD list */ pd_count = MRSAS_MAX_PD; pd_addr = pd_list_mem->addr; if (pd_list_mem->count < pd_count) { memset(sc->local_pd_list, 0, MRSAS_MAX_PD * sizeof(struct mrsas_pd_list)); for (pd_index = 0; pd_index < pd_list_mem->count; pd_index++) { sc->local_pd_list[pd_addr->deviceId].tid = pd_addr->deviceId; sc->local_pd_list[pd_addr->deviceId].driveType = pd_addr->scsiDevType; sc->local_pd_list[pd_addr->deviceId].driveState = MR_PD_STATE_SYSTEM; if (sc->target_list[pd_addr->deviceId].target_id == 0xffff) mrsas_add_target(sc, pd_addr->deviceId); pd_addr++; } for (pd_index = 0; pd_index < MRSAS_MAX_PD; pd_index++) { if ((sc->local_pd_list[pd_index].driveState != MR_PD_STATE_SYSTEM) && (sc->target_list[pd_index].target_id != 0xffff)) { mrsas_remove_target(sc, pd_index); } } /* * Use mutext/spinlock if pd_list component size increase more than * 32 bit. */ memcpy(sc->pd_list, sc->local_pd_list, sizeof(sc->local_pd_list)); do_ocr = 0; } dcmd_timeout: mrsas_free_tmp_dcmd(tcmd); free(tcmd, M_MRSAS); if (do_ocr) sc->do_timedout_reset = MFI_DCMD_TIMEOUT_OCR; if (!sc->mask_interrupts) mrsas_release_mfi_cmd(cmd); return (retcode); } /* * mrsas_get_ld_list: Returns FW's LD list structure input: * Adapter soft state * * Issues an internal command (DCMD) to get the FW's controller PD list * structure. This information is mainly used to find out about supported by * the FW. */ static int mrsas_get_ld_list(struct mrsas_softc *sc) { int ld_list_size, retcode = 0, ld_index = 0, ids = 0, drv_tgt_id; u_int8_t do_ocr = 1; struct mrsas_mfi_cmd *cmd; struct mrsas_dcmd_frame *dcmd; struct MR_LD_LIST *ld_list_mem; bus_addr_t ld_list_phys_addr = 0; struct mrsas_tmp_dcmd *tcmd; cmd = mrsas_get_mfi_cmd(sc); if (!cmd) { device_printf(sc->mrsas_dev, "Cannot alloc for get LD list cmd\n"); return 1; } dcmd = &cmd->frame->dcmd; tcmd = malloc(sizeof(struct mrsas_tmp_dcmd), M_MRSAS, M_NOWAIT); ld_list_size = sizeof(struct MR_LD_LIST); if (mrsas_alloc_tmp_dcmd(sc, tcmd, ld_list_size) != SUCCESS) { device_printf(sc->mrsas_dev, "Cannot alloc dmamap for get LD list cmd\n"); mrsas_release_mfi_cmd(cmd); mrsas_free_tmp_dcmd(tcmd); free(tcmd, M_MRSAS); return (ENOMEM); } else { ld_list_mem = tcmd->tmp_dcmd_mem; ld_list_phys_addr = tcmd->tmp_dcmd_phys_addr; } memset(dcmd->mbox.b, 0, MFI_MBOX_SIZE); if (sc->max256vdSupport) dcmd->mbox.b[0] = 1; dcmd->cmd = MFI_CMD_DCMD; dcmd->cmd_status = 0xFF; dcmd->sge_count = 1; dcmd->flags = MFI_FRAME_DIR_READ; dcmd->timeout = 0; dcmd->data_xfer_len = sizeof(struct MR_LD_LIST); dcmd->opcode = MR_DCMD_LD_GET_LIST; dcmd->sgl.sge32[0].phys_addr = ld_list_phys_addr; dcmd->sgl.sge32[0].length = sizeof(struct MR_LD_LIST); dcmd->pad_0 = 0; if (!sc->mask_interrupts) retcode = mrsas_issue_blocked_cmd(sc, cmd); else retcode = mrsas_issue_polled(sc, cmd); if (retcode == ETIMEDOUT) goto dcmd_timeout; #if VD_EXT_DEBUG printf("Number of LDs %d\n", ld_list_mem->ldCount); #endif /* Get the instance LD list */ if (ld_list_mem->ldCount <= sc->fw_supported_vd_count) { sc->CurLdCount = ld_list_mem->ldCount; memset(sc->ld_ids, 0xff, MAX_LOGICAL_DRIVES_EXT); for (ld_index = 0; ld_index < ld_list_mem->ldCount; ld_index++) { ids = ld_list_mem->ldList[ld_index].ref.ld_context.targetId; drv_tgt_id = ids + MRSAS_MAX_PD; if (ld_list_mem->ldList[ld_index].state != 0) { sc->ld_ids[ids] = ld_list_mem->ldList[ld_index].ref.ld_context.targetId; if (sc->target_list[drv_tgt_id].target_id == 0xffff) mrsas_add_target(sc, drv_tgt_id); } else { if (sc->target_list[drv_tgt_id].target_id != 0xffff) mrsas_remove_target(sc, drv_tgt_id); } } do_ocr = 0; } dcmd_timeout: mrsas_free_tmp_dcmd(tcmd); free(tcmd, M_MRSAS); if (do_ocr) sc->do_timedout_reset = MFI_DCMD_TIMEOUT_OCR; if (!sc->mask_interrupts) mrsas_release_mfi_cmd(cmd); return (retcode); } /* * mrsas_alloc_tmp_dcmd: Allocates memory for temporary command input: * Adapter soft state Temp command Size of alloction * * Allocates DMAable memory for a temporary internal command. The allocated * memory is initialized to all zeros upon successful loading of the dma * mapped memory. */ int mrsas_alloc_tmp_dcmd(struct mrsas_softc *sc, struct mrsas_tmp_dcmd *tcmd, int size) { if (bus_dma_tag_create(sc->mrsas_parent_tag, 1, 0, BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL, size, 1, size, BUS_DMA_ALLOCNOW, NULL, NULL, &tcmd->tmp_dcmd_tag)) { device_printf(sc->mrsas_dev, "Cannot allocate tmp dcmd tag\n"); return (ENOMEM); } if (bus_dmamem_alloc(tcmd->tmp_dcmd_tag, (void **)&tcmd->tmp_dcmd_mem, BUS_DMA_NOWAIT, &tcmd->tmp_dcmd_dmamap)) { device_printf(sc->mrsas_dev, "Cannot allocate tmp dcmd mem\n"); return (ENOMEM); } if (bus_dmamap_load(tcmd->tmp_dcmd_tag, tcmd->tmp_dcmd_dmamap, tcmd->tmp_dcmd_mem, size, mrsas_addr_cb, &tcmd->tmp_dcmd_phys_addr, BUS_DMA_NOWAIT)) { device_printf(sc->mrsas_dev, "Cannot load tmp dcmd mem\n"); return (ENOMEM); } memset(tcmd->tmp_dcmd_mem, 0, size); return (0); } /* * mrsas_free_tmp_dcmd: Free memory for temporary command input: * temporary dcmd pointer * * Deallocates memory of the temporary command for use in the construction of * the internal DCMD. */ void mrsas_free_tmp_dcmd(struct mrsas_tmp_dcmd *tmp) { if (tmp->tmp_dcmd_phys_addr) bus_dmamap_unload(tmp->tmp_dcmd_tag, tmp->tmp_dcmd_dmamap); if (tmp->tmp_dcmd_mem != NULL) bus_dmamem_free(tmp->tmp_dcmd_tag, tmp->tmp_dcmd_mem, tmp->tmp_dcmd_dmamap); if (tmp->tmp_dcmd_tag != NULL) bus_dma_tag_destroy(tmp->tmp_dcmd_tag); } /* * mrsas_issue_blocked_abort_cmd: Aborts previously issued cmd input: * Adapter soft state Previously issued cmd to be aborted * * This function is used to abort previously issued commands, such as AEN and * RAID map sync map commands. The abort command is sent as a DCMD internal * command and subsequently the driver will wait for a return status. The * max wait time is MRSAS_INTERNAL_CMD_WAIT_TIME seconds. */ static int mrsas_issue_blocked_abort_cmd(struct mrsas_softc *sc, struct mrsas_mfi_cmd *cmd_to_abort) { struct mrsas_mfi_cmd *cmd; struct mrsas_abort_frame *abort_fr; u_int8_t retcode = 0; unsigned long total_time = 0; u_int8_t max_wait = MRSAS_INTERNAL_CMD_WAIT_TIME; cmd = mrsas_get_mfi_cmd(sc); if (!cmd) { device_printf(sc->mrsas_dev, "Cannot alloc for abort cmd\n"); return (1); } abort_fr = &cmd->frame->abort; /* Prepare and issue the abort frame */ abort_fr->cmd = MFI_CMD_ABORT; abort_fr->cmd_status = 0xFF; abort_fr->flags = 0; abort_fr->abort_context = cmd_to_abort->index; abort_fr->abort_mfi_phys_addr_lo = cmd_to_abort->frame_phys_addr; abort_fr->abort_mfi_phys_addr_hi = 0; cmd->sync_cmd = 1; cmd->cmd_status = 0xFF; if (mrsas_issue_dcmd(sc, cmd)) { device_printf(sc->mrsas_dev, "Fail to send abort command.\n"); return (1); } /* Wait for this cmd to complete */ sc->chan = (void *)&cmd; while (1) { if (cmd->cmd_status == 0xFF) { tsleep((void *)&sc->chan, 0, "mrsas_sleep", hz); } else break; total_time++; if (total_time >= max_wait) { device_printf(sc->mrsas_dev, "Abort cmd timed out after %d sec.\n", max_wait); retcode = 1; break; } } cmd->sync_cmd = 0; mrsas_release_mfi_cmd(cmd); return (retcode); } /* * mrsas_complete_abort: Completes aborting a command input: * Adapter soft state Cmd that was issued to abort another cmd * * The mrsas_issue_blocked_abort_cmd() function waits for the command status to * change after sending the command. This function is called from * mrsas_complete_mptmfi_passthru() to wake up the sleep thread associated. */ void mrsas_complete_abort(struct mrsas_softc *sc, struct mrsas_mfi_cmd *cmd) { if (cmd->sync_cmd) { cmd->sync_cmd = 0; cmd->cmd_status = 0; sc->chan = (void *)&cmd; wakeup_one((void *)&sc->chan); } return; } /* * mrsas_aen_handler: AEN processing callback function from thread context * input: Adapter soft state * * Asynchronous event handler */ void mrsas_aen_handler(struct mrsas_softc *sc) { union mrsas_evt_class_locale class_locale; int doscan = 0; u_int32_t seq_num; int error, fail_aen = 0; if (sc == NULL) { printf("invalid instance!\n"); return; } if (sc->remove_in_progress || sc->reset_in_progress) { device_printf(sc->mrsas_dev, "Returning from %s, line no %d\n", __func__, __LINE__); return; } if (sc->evt_detail_mem) { switch (sc->evt_detail_mem->code) { case MR_EVT_PD_INSERTED: fail_aen = mrsas_get_pd_list(sc); if (!fail_aen) mrsas_bus_scan_sim(sc, sc->sim_1); else goto skip_register_aen; break; case MR_EVT_PD_REMOVED: fail_aen = mrsas_get_pd_list(sc); if (!fail_aen) mrsas_bus_scan_sim(sc, sc->sim_1); else goto skip_register_aen; break; case MR_EVT_LD_OFFLINE: case MR_EVT_CFG_CLEARED: case MR_EVT_LD_DELETED: mrsas_bus_scan_sim(sc, sc->sim_0); break; case MR_EVT_LD_CREATED: fail_aen = mrsas_get_ld_list(sc); if (!fail_aen) mrsas_bus_scan_sim(sc, sc->sim_0); else goto skip_register_aen; break; case MR_EVT_CTRL_HOST_BUS_SCAN_REQUESTED: case MR_EVT_FOREIGN_CFG_IMPORTED: case MR_EVT_LD_STATE_CHANGE: doscan = 1; break; case MR_EVT_CTRL_PROP_CHANGED: fail_aen = mrsas_get_ctrl_info(sc); if (fail_aen) goto skip_register_aen; break; default: break; } } else { device_printf(sc->mrsas_dev, "invalid evt_detail\n"); return; } if (doscan) { fail_aen = mrsas_get_pd_list(sc); if (!fail_aen) { mrsas_dprint(sc, MRSAS_AEN, "scanning ...sim 1\n"); mrsas_bus_scan_sim(sc, sc->sim_1); } else goto skip_register_aen; fail_aen = mrsas_get_ld_list(sc); if (!fail_aen) { mrsas_dprint(sc, MRSAS_AEN, "scanning ...sim 0\n"); mrsas_bus_scan_sim(sc, sc->sim_0); } else goto skip_register_aen; } seq_num = sc->evt_detail_mem->seq_num + 1; /* Register AEN with FW for latest sequence number plus 1 */ class_locale.members.reserved = 0; class_locale.members.locale = MR_EVT_LOCALE_ALL; class_locale.members.class = MR_EVT_CLASS_DEBUG; if (sc->aen_cmd != NULL) return; mtx_lock(&sc->aen_lock); error = mrsas_register_aen(sc, seq_num, class_locale.word); mtx_unlock(&sc->aen_lock); if (error) device_printf(sc->mrsas_dev, "register aen failed error %x\n", error); skip_register_aen: return; } /* * mrsas_complete_aen: Completes AEN command * input: Adapter soft state * Cmd that was issued to abort another cmd * * This function will be called from ISR and will continue event processing from * thread context by enqueuing task in ev_tq (callback function * "mrsas_aen_handler"). */ void mrsas_complete_aen(struct mrsas_softc *sc, struct mrsas_mfi_cmd *cmd) { /* * Don't signal app if it is just an aborted previously registered * aen */ if ((!cmd->abort_aen) && (sc->remove_in_progress == 0)) { sc->mrsas_aen_triggered = 1; mtx_lock(&sc->aen_lock); if (sc->mrsas_poll_waiting) { sc->mrsas_poll_waiting = 0; selwakeup(&sc->mrsas_select); } mtx_unlock(&sc->aen_lock); } else cmd->abort_aen = 0; sc->aen_cmd = NULL; mrsas_release_mfi_cmd(cmd); taskqueue_enqueue(sc->ev_tq, &sc->ev_task); return; } static device_method_t mrsas_methods[] = { DEVMETHOD(device_probe, mrsas_probe), DEVMETHOD(device_attach, mrsas_attach), DEVMETHOD(device_detach, mrsas_detach), + DEVMETHOD(device_shutdown, mrsas_shutdown), DEVMETHOD(device_suspend, mrsas_suspend), DEVMETHOD(device_resume, mrsas_resume), DEVMETHOD(bus_print_child, bus_generic_print_child), DEVMETHOD(bus_driver_added, bus_generic_driver_added), {0, 0} }; static driver_t mrsas_driver = { "mrsas", mrsas_methods, sizeof(struct mrsas_softc) }; static devclass_t mrsas_devclass; DRIVER_MODULE(mrsas, pci, mrsas_driver, mrsas_devclass, 0, 0); MODULE_DEPEND(mrsas, cam, 1, 1, 1); Index: stable/12 =================================================================== --- stable/12 (revision 349208) +++ stable/12 (revision 349209) Property changes on: stable/12 ___________________________________________________________________ Modified: svn:mergeinfo ## -0,0 +0,1 ## Merged /head:r348159
|
__label__pos
| 0.996711 |
Commit bfaf6b6e authored by Alex Bronstein's avatar Alex Bronstein
Browse files
Issue #2758897 by Wim Leers, damiankloip, larowlan: Move rest module's "link...
Issue #2758897 by Wim Leers, damiankloip, larowlan: Move rest module's "link manager" services to serialization module
parent 414574e1
......@@ -5,5 +5,4 @@ package: Web services
version: VERSION
core: 8.x
dependencies:
- rest
- serialization
services:
serializer.normalizer.entity_reference_item.hal:
class: Drupal\hal\Normalizer\EntityReferenceItemNormalizer
arguments: ['@rest.link_manager', '@serializer.entity_resolver']
arguments: ['@serialization.link_manager', '@serializer.entity_resolver']
tags:
- { name: normalizer, priority: 10 }
serializer.normalizer.field_item.hal:
......@@ -16,10 +16,10 @@ services:
class: Drupal\hal\Normalizer\FileEntityNormalizer
tags:
- { name: normalizer, priority: 20 }
arguments: ['@entity.manager', '@http_client', '@rest.link_manager', '@module_handler']
arguments: ['@entity.manager', '@http_client', '@serialization.link_manager', '@module_handler']
serializer.normalizer.entity.hal:
class: Drupal\hal\Normalizer\ContentEntityNormalizer
arguments: ['@rest.link_manager', '@entity.manager', '@module_handler']
arguments: ['@serialization.link_manager', '@entity.manager', '@module_handler']
tags:
- { name: normalizer, priority: 10 }
serializer.encoder.hal:
......
......@@ -6,7 +6,7 @@
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Entity\EntityManagerInterface;
use Drupal\Core\Extension\ModuleHandlerInterface;
use Drupal\rest\LinkManager\LinkManagerInterface;
use Drupal\serialization\LinkManager\LinkManagerInterface;
use Drupal\serialization\Normalizer\FieldableEntityNormalizerTrait;
use Symfony\Component\Serializer\Exception\UnexpectedValueException;
......@@ -27,7 +27,7 @@ class ContentEntityNormalizer extends NormalizerBase {
/**
* The hypermedia link manager.
*
* @var \Drupal\rest\LinkManager\LinkManagerInterface
* @var \Drupal\serialization\LinkManager\LinkManagerInterface
*/
protected $linkManager;
......@@ -41,7 +41,7 @@ class ContentEntityNormalizer extends NormalizerBase {
/**
* Constructs an ContentEntityNormalizer object.
*
* @param \Drupal\rest\LinkManager\LinkManagerInterface $link_manager
* @param \Drupal\serialization\LinkManager\LinkManagerInterface $link_manager
* The hypermedia link manager.
*/
public function __construct(LinkManagerInterface $link_manager, EntityManagerInterface $entity_manager, ModuleHandlerInterface $module_handler) {
......
......@@ -3,7 +3,7 @@
namespace Drupal\hal\Normalizer;
use Drupal\Core\Entity\FieldableEntityInterface;
use Drupal\rest\LinkManager\LinkManagerInterface;
use Drupal\serialization\LinkManager\LinkManagerInterface;
use Drupal\serialization\EntityResolver\EntityResolverInterface;
use Drupal\serialization\EntityResolver\UuidReferenceInterface;
......@@ -22,7 +22,7 @@ class EntityReferenceItemNormalizer extends FieldItemNormalizer implements UuidR
/**
* The hypermedia link manager.
*
* @var \Drupal\rest\LinkManager\LinkManagerInterface
* @var \Drupal\serialization\LinkManager\LinkManagerInterface
*/
protected $linkManager;
......@@ -36,7 +36,7 @@ class EntityReferenceItemNormalizer extends FieldItemNormalizer implements UuidR
/**
* Constructs an EntityReferenceItemNormalizer object.
*
* @param \Drupal\rest\LinkManager\LinkManagerInterface $link_manager
* @param \Drupal\serialization\LinkManager\LinkManagerInterface $link_manager
* The hypermedia link manager.
* @param \Drupal\serialization\EntityResolver\EntityResolverInterface $entity_Resolver
* The entity resolver.
......
......@@ -4,7 +4,7 @@
use Drupal\Core\Entity\EntityManagerInterface;
use Drupal\Core\Extension\ModuleHandlerInterface;
use Drupal\rest\LinkManager\LinkManagerInterface;
use Drupal\serialization\LinkManager\LinkManagerInterface;
use GuzzleHttp\ClientInterface;
/**
......@@ -33,7 +33,7 @@ class FileEntityNormalizer extends ContentEntityNormalizer {
* The entity manager.
* @param \GuzzleHttp\ClientInterface $http_client
* The HTTP Client.
* @param \Drupal\rest\LinkManager\LinkManagerInterface $link_manager
* @param \Drupal\serialization\LinkManager\LinkManagerInterface $link_manager
* The hypermedia link manager.
* @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler
* The module handler.
......
......@@ -7,9 +7,9 @@
use Drupal\hal\Encoder\JsonEncoder;
use Drupal\hal\Normalizer\FieldItemNormalizer;
use Drupal\hal\Normalizer\FileEntityNormalizer;
use Drupal\rest\LinkManager\LinkManager;
use Drupal\rest\LinkManager\RelationLinkManager;
use Drupal\rest\LinkManager\TypeLinkManager;
use Drupal\serialization\LinkManager\LinkManager;
use Drupal\serialization\LinkManager\RelationLinkManager;
use Drupal\serialization\LinkManager\TypeLinkManager;
use Symfony\Component\Serializer\Serializer;
......
......@@ -10,9 +10,9 @@
use Drupal\hal\Normalizer\FieldItemNormalizer;
use Drupal\hal\Normalizer\FieldNormalizer;
use Drupal\language\Entity\ConfigurableLanguage;
use Drupal\rest\LinkManager\LinkManager;
use Drupal\rest\LinkManager\RelationLinkManager;
use Drupal\rest\LinkManager\TypeLinkManager;
use Drupal\serialization\LinkManager\LinkManager;
use Drupal\serialization\LinkManager\RelationLinkManager;
use Drupal\serialization\LinkManager\TypeLinkManager;
use Drupal\serialization\EntityResolver\ChainEntityResolver;
use Drupal\serialization\EntityResolver\TargetIdResolver;
use Drupal\serialization\EntityResolver\UuidResolver;
......@@ -30,7 +30,7 @@ abstract class NormalizerTestBase extends KernelTestBase {
*
* @var array
*/
public static $modules = ['entity_test', 'field', 'hal', 'language', 'rest', 'serialization', 'system', 'text', 'user', 'filter'];
public static $modules = ['entity_test', 'field', 'hal', 'language', 'serialization', 'system', 'text', 'user', 'filter'];
/**
* The mock serializer.
......
# Set the domain for REST type and relation links.
# If left blank, the site's domain will be used.
link_domain: ~
# Before Drupal 8.2, EntityResource used permissions as well as the entity
# access system for access checking. This was confusing, and it only did this
# for historical reasons. New Drupal installations opt out from this by default
......
......@@ -3,6 +3,7 @@ rest.settings:
type: config_object
label: 'REST settings'
mapping:
# @deprecated in Drupal 8.3.x and will be removed before Drupal 9.0.0.
link_domain:
type: string
label: 'Domain of the relation'
......
......@@ -31,6 +31,9 @@ function hook_rest_resource_alter(&$definitions) {
/**
* Alter the REST type URI.
*
* @deprecated in Drupal 8.3.x and will be removed before Drupal 9.0.0. Use
* hook_serialization_type_uri_alter() instead. This exists solely for BC.
*
* Modules may wish to alter the type URI generated for a resource based on the
* context of the serializer/normalizer operation.
*
......@@ -46,7 +49,7 @@ function hook_rest_resource_alter(&$definitions) {
*/
function hook_rest_type_uri_alter(&$uri, $context = array()) {
if ($context['mymodule'] == TRUE) {
$base = \Drupal::config('rest.settings')->get('link_domain');
$base = \Drupal::config('serialization.settings')->get('link_domain');
$uri = str_replace($base, 'http://mymodule.domain', $uri);
}
}
......@@ -55,6 +58,9 @@ function hook_rest_type_uri_alter(&$uri, $context = array()) {
/**
* Alter the REST relation URI.
*
* @deprecated in Drupal 8.3.x and will be removed before Drupal 9.0.0. Use
* hook_serialization_relation_uri_alter() instead. This exists solely for BC.
*
* Modules may wish to alter the relation URI generated for a resource based on
* the context of the serializer/normalizer operation.
*
......@@ -70,7 +76,7 @@ function hook_rest_type_uri_alter(&$uri, $context = array()) {
*/
function hook_rest_relation_uri_alter(&$uri, $context = array()) {
if ($context['mymodule'] == TRUE) {
$base = \Drupal::config('rest.settings')->get('link_domain');
$base = \Drupal::config('serialization.settings')->get('link_domain');
$uri = str_replace($base, 'http://mymodule.domain', $uri);
}
}
......
......@@ -11,15 +11,22 @@ services:
# @todo Remove this service in Drupal 9.0.0.
access_check.rest.csrf:
alias: access_check.header.csrf
# Link managers.
# @deprecated in Drupal 8.3.x and will be removed before 9.0.0. Use
# serialization.link_manager instead.
rest.link_manager:
parent: serialization.link_manager
class: Drupal\rest\LinkManager\LinkManager
arguments: ['@rest.link_manager.type', '@rest.link_manager.relation']
# @deprecated in Drupal 8.3.x and will be removed before 9.0.0. Use
# serialization.link_manager.type instead.
rest.link_manager.type:
parent: serialization.link_manager.type
class: Drupal\rest\LinkManager\TypeLinkManager
arguments: ['@cache.default', '@module_handler', '@config.factory', '@request_stack', '@entity_type.bundle.info']
# @deprecated in Drupal 8.3.x and will be removed before 9.0.0. Use
# serialization.link_manager.relation instead.
rest.link_manager.relation:
parent: serialization.link_manager.relation
class: Drupal\rest\LinkManager\RelationLinkManager
arguments: ['@cache.default', '@entity.manager', '@module_handler', '@config.factory', '@request_stack']
rest.resource_routes:
class: Drupal\rest\Routing\ResourceRoutes
arguments: ['@plugin.manager.rest', '@entity_type.manager', '@logger.channel.rest']
......
......@@ -2,19 +2,10 @@
namespace Drupal\rest\LinkManager;
use Drupal\serialization\LinkManager\ConfigurableLinkManagerInterface as MovedConfigurableLinkManagerInterface;
/**
* Defines an interface for a link manager with a configurable domain.
* @deprecated in Drupal 8.3.x and will be removed before Drupal 9.0.0. This has
* been moved to the serialization module. This exists solely for BC.
*/
interface ConfigurableLinkManagerInterface {
/**
* Sets the link domain used in constructing link URIs.
*
* @param string $domain
* The link domain to use for constructing link URIs.
*
* @return $this
*/
public function setLinkDomain($domain);
}
interface ConfigurableLinkManagerInterface extends MovedConfigurableLinkManagerInterface {}
......@@ -2,70 +2,10 @@
namespace Drupal\rest\LinkManager;
class LinkManager implements LinkManagerInterface {
use Drupal\serialization\LinkManager\LinkManager as MovedLinkManager;
/**
* The type link manager.
*
* @var \Drupal\rest\LinkManager\TypeLinkManagerInterface
*/
protected $typeLinkManager;
/**
* The relation link manager.
*
* @var \Drupal\rest\LinkManager\RelationLinkManagerInterface
*/
protected $relationLinkManager;
/**
* Constructor.
*
* @param \Drupal\rest\LinkManager\TypeLinkManagerInterface $type_link_manager
* Manager for handling bundle URIs.
* @param \Drupal\rest\LinkManager\RelationLinkManagerInterface $relation_link_manager
* Manager for handling bundle URIs.
*/
public function __construct(TypeLinkManagerInterface $type_link_manager, RelationLinkManagerInterface $relation_link_manager) {
$this->typeLinkManager = $type_link_manager;
$this->relationLinkManager = $relation_link_manager;
}
/**
* {@inheritdoc}
*/
public function getTypeUri($entity_type, $bundle, $context = array()) {
return $this->typeLinkManager->getTypeUri($entity_type, $bundle, $context);
}
/**
* {@inheritdoc}
*/
public function getTypeInternalIds($type_uri, $context = array()) {
return $this->typeLinkManager->getTypeInternalIds($type_uri, $context);
}
/**
* {@inheritdoc}
*/
public function getRelationUri($entity_type, $bundle, $field_name, $context = array()) {
return $this->relationLinkManager->getRelationUri($entity_type, $bundle, $field_name, $context);
}
/**
* {@inheritdoc}
*/
public function getRelationInternalIds($relation_uri) {
return $this->relationLinkManager->getRelationInternalIds($relation_uri);
}
/**
* {@inheritdoc}
*/
public function setLinkDomain($domain) {
$this->relationLinkManager->setLinkDomain($domain);
$this->typeLinkManager->setLinkDomain($domain);
return $this;
}
}
/**
* @deprecated in Drupal 8.3.x and will be removed before Drupal 9.0.0. This has
* been moved to the serialization module. This exists solely for BC.
*/
class LinkManager extends MovedLinkManager implements LinkManagerInterface {}
......@@ -2,57 +2,10 @@
namespace Drupal\rest\LinkManager;
use Drupal\serialization\LinkManager\LinkManagerBase as MovedLinkManagerBase;
/**
* Defines an abstract base-class for REST link manager objects.
* @deprecated in Drupal 8.3.x and will be removed before Drupal 9.0.0. This has
* been moved to the serialization module. This exists solely for BC.
*/
abstract class LinkManagerBase {
/**
* Link domain used for type links URIs.
*
* @var string
*/
protected $linkDomain;
/**
* Config factory service.
*
* @var \Drupal\Core\Config\ConfigFactoryInterface
*/
protected $configFactory;
/**
* The request stack.
*
* @var \Symfony\Component\HttpFoundation\RequestStack
*/
protected $requestStack;
/**
* {@inheritdoc}
*/
public function setLinkDomain($domain) {
$this->linkDomain = rtrim($domain, '/');
return $this;
}
/**
* Gets the link domain.
*
* @return string
* The link domain.
*/
protected function getLinkDomain() {
if (empty($this->linkDomain)) {
if ($domain = $this->configFactory->get('rest.settings')->get('link_domain')) {
$this->linkDomain = rtrim($domain, '/');
}
else {
$request = $this->requestStack->getCurrentRequest();
$this->linkDomain = $request->getSchemeAndHttpHost() . $request->getBasePath();
}
}
return $this->linkDomain;
}
}
abstract class LinkManagerBase extends MovedLinkManagerBase {}
......@@ -2,17 +2,10 @@
namespace Drupal\rest\LinkManager;
use Drupal\serialization\LinkManager\LinkManagerInterface as MovedLinkManagerInterface;
/**
* Interface implemented by link managers.
*
* There are no explicit methods on the manager interface. Instead link managers
* broker the interactions of the different components, and therefore must
* implement each component interface, which is enforced by this interface
* extending all of the component ones.
*
* While a link manager may directly implement these interface methods with
* custom logic, it is expected to be more common for plugin managers to proxy
* the method invocations to the respective components.
* @deprecated in Drupal 8.3.x and will be removed before Drupal 9.0.0. This has
* been moved to the serialization module. This exists solely for BC.
*/
interface LinkManagerInterface extends TypeLinkManagerInterface, RelationLinkManagerInterface {
}
interface LinkManagerInterface extends MovedLinkManagerInterface {}
......@@ -2,141 +2,10 @@
namespace Drupal\rest\LinkManager;
use Drupal\Core\Cache\Cache;
use Drupal\Core\Cache\CacheBackendInterface;
use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\Core\Entity\ContentEntityTypeInterface;
use Drupal\Core\Entity\EntityManagerInterface;
use Drupal\Core\Extension\ModuleHandlerInterface;
use Symfony\Component\HttpFoundation\RequestStack;
use Drupal\serialization\LinkManager\RelationLinkManager as MovedLinkRelationManager;
class RelationLinkManager extends LinkManagerBase implements RelationLinkManagerInterface {
/**
* @var \Drupal\Core\Cache\CacheBackendInterface;
*/
protected $cache;
/**
* Entity manager.
*
* @var \Drupal\Core\Entity\EntityManagerInterface
*/
protected $entityManager;
/**
* Module handler service.
*
* @var \Drupal\Core\Extension\ModuleHandlerInterface
*/
protected $moduleHandler;
/**
* Constructor.
*
* @param \Drupal\Core\Cache\CacheBackendInterface $cache
* The cache of relation URIs and their associated Typed Data IDs.
* @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager
* The entity manager.
* @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler
* The module handler service.
* @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory
* The config factory service.
* @param \Symfony\Component\HttpFoundation\RequestStack $request_stack
* The request stack.
*/
public function __construct(CacheBackendInterface $cache, EntityManagerInterface $entity_manager, ModuleHandlerInterface $module_handler, ConfigFactoryInterface $config_factory, RequestStack $request_stack) {
$this->cache = $cache;
$this->entityManager = $entity_manager;
$this->configFactory = $config_factory;
$this->moduleHandler = $module_handler;
$this->requestStack = $request_stack;
}
/**
* {@inheritdoc}
*/
public function getRelationUri($entity_type, $bundle, $field_name, $context = array()) {
// Per the interface documention of this method, the returned URI may
// optionally also serve as the URL of a documentation page about this
// field. However, the REST module does not currently implement such
// a documentation page. Therefore, we return a URI assembled relative to
// the site's base URL, which is sufficient to uniquely identify the site's
// entity type + bundle + field for use in hypermedia formats, but we do
// not take into account unclean URLs, language prefixing, or anything else
// that would be required for Drupal to be able to respond with content
// at this URL. If a module is installed that adds such content, but
// requires this URL to be different (e.g., include a language prefix),
// then the module must also override the RelationLinkManager class/service
// to return the desired URL.
$uri = $this->getLinkDomain() . "/rest/relation/$entity_type/$bundle/$field_name";
$this->moduleHandler->alter('rest_relation_uri', $uri, $context);
return $uri;
}
/**
* {@inheritdoc}
*/
public function getRelationInternalIds($relation_uri, $context = array()) {
$relations = $this->getRelations($context);
if (isset($relations[$relation_uri])) {
return $relations[$relation_uri];
}
return FALSE;
}
/**
* Get the array of relation links.
*
* Any field can be handled as a relation simply by changing how it is
* normalized. Therefore, there is no prior knowledge that can be used here
* to determine which fields to assign relation URIs. Instead, each field,
* even primitives, are given a relation URI. It is up to the caller to
* determine which URIs to use.
*
* @param array $context
* Context from the normalizer/serializer operation.
*
* @return array
* An array of typed data ids (entity_type, bundle, and field name) keyed
* by corresponding relation URI.
*/
protected function getRelations($context = array()) {
$cid = 'rest:links:relations';
$cache = $this->cache->get($cid);
if (!$cache) {
$this->writeCache($context);
$cache = $this->cache->get($cid);
}
return $cache->data;
}
/**
* Writes the cache of relation links.
*
* @param array $context
* Context from the normalizer/serializer operation.
*/
protected function writeCache($context = array()) {
$data = array();
foreach ($this->entityManager->getDefinitions() as $entity_type) {
if ($entity_type instanceof ContentEntityTypeInterface) {
foreach ($this->entityManager->getBundleInfo($entity_type->id()) as $bundle => $bundle_info) {
foreach ($this->entityManager->getFieldDefinitions($entity_type->id(), $bundle) as $field_definition) {
$relation_uri = $this->getRelationUri($entity_type->id(), $bundle, $field_definition->getName(), $context);
$data[$relation_uri] = array(
'entity_type' => $entity_type,
'bundle' => $bundle,
'field_name' => $field_definition->getName(),
);
}
}
}
}
// These URIs only change when field info changes, so cache it permanently
// and only clear it when the fields cache is cleared.
$this->cache->set('rest:links:relations', $data, Cache::PERMANENT, array('entity_field_info'));
}
}
/**
* @deprecated in Drupal 8.3.x and will be removed before Drupal 9.0.0. This has
* been moved to the serialization module. This exists solely for BC.
*/
class RelationLinkManager extends MovedLinkRelationManager implements RelationLinkManagerInterface {}
......@@ -2,38 +2,10 @@
namespace Drupal\rest\LinkManager;
interface RelationLinkManagerInterface extends ConfigurableLinkManagerInterface {
use Drupal\serialization\LinkManager\RelationLinkManagerInterface as MovedRelationLinkManagerInterface;
/**
* Gets the URI that corresponds to a field.
*
* When using hypermedia formats, this URI can be used to indicate which
* field the data represents. Documentation about this field can also be
* provided at this URI.
*
* @param string $entity_type
* The bundle's entity type.
* @param string $bundle
* The bundle name.
* @param string $field_name
* The field name.
* @param array $context
* (optional) Optional serializer/normalizer context.
*
* @return string
* The corresponding URI for the field.
*/
public function getRelationUri($entity_type, $bundle, $field_name, $context = array());
/**
* Translates a REST URI into internal IDs.
*
* @param string $relation_uri
* Relation URI to transform into internal IDs
*
* @return array
* Array with keys 'entity_type', 'bundle' and 'field_name'.
*/
public function getRelationInternalIds($relation_uri);
}
/**
* @deprecated in Drupal 8.3.x and will be removed before Drupal 9.0.0. This has
* been moved to the serialization module. This exists solely for BC.
*/
interface RelationLinkManagerInterface extends MovedRelationLinkManagerInterface {}
......@@ -2,148 +2,10 @@
namespace Drupal\rest\LinkManager;
|
__label__pos
| 0.936994 |
Sandesh – A SDN Analytics Interface
In a previous blog posting titled “Debugging and System Visibility in a SDN Environment”, OpenContrail Software Engineer and my colleague, Anish Mehta, gave an overview of the challenges and opportunities facing SDN Analytics.
A SDN analytics solution needs to have the right abstractions, aggregation, and syncing mechanisms to report and present information that can be used by humans to operate a multi-tenant datacenter. Open APIs for both the northbound and the southbound analytics interface of the SDN controller are crucial to operate in a multi-vendor environment. The southbound interface here refers to the interface to gather information from both virtual and physical routers, gateways and network services appliances. Traditionally, the southbound interface consists of protocols like syslog, sFlow, netFlow, SNMP used by network elements to report information. Proprietary CLI commands generally display the current operational state of the network elements. OpenContrail Analytics node uses REST as the northbound interface and Sandesh as the southbound interface as shown below.
sandesh_analytics_blogpost_picture
Figure 1: OpenContrail Analytics Node
In this blog post, we will present an overview of “Sandesh” – A southbound interface protocol that is used by the OpenContrail Analytics engine to gather information from the OpenContrail virtual routers and other software modules like the control-node, and the configuration manager, which run as part of the controller. The name Sandesh comes from Sanskrit and means message. Sandesh consists of three components:
1. An Interface Definition Language (IDL) and code generator based on Apache Thrift that allows users/developers to specify messages.
2. XML-based protocol that is used between the generators of the information and the collector of the information, which is the analytics engine
3. A back-end library used by the generators that integrates the generated code into an asynchronous queue based sending mechanism.
The languages currently supported are C++, Python, and C. The C language support is limited to serialization and deserialization.
The blog post will concentrate on the IDL and explain how the IDL allows the specification of abstractions, aggregation, and syncing mechanisms to be applied by the analytics engine to the messages defined in the IDL. The Juniper /contrail-sandesh Github repository contains source code to help you get started. Readers interested in learning more about the XML-based protocol and the back-end library can look under the library/cpp/protocol for C++ and library/python/pysandesh/protocol for Python based implementation.
Sandesh IDL and code generator:
The Sandesh code generator allows developers to define data types and messages to be sent to the analytics engine or the collector in a simple definition file. Taking that file as input, the code generator produces code to be used to send the messages to the collector. The code generator frees the developer from the burden of writing a load of boilerplate code to serialize and transport the objects to the collector. The developers are exposed a simple API to send the messages and the generated code along with the back-end library handles the grunt work of actually doing the low-level serialization/deserialization and send/receive. The data types supported in the IDL file are bool, byte, i16, i32, i64, string, list, map, struct, sandesh, u16, u32, u64, const static string. The sandesh data-type is the top-level data type and identifies a unique message type being sent from the generator to the collector. Developers can define different types of sandesh based on the need to convey different types of information to the collector. Annotations are used in the IDL file to convey additional information like the abstraction to index the message against, aggregation mechanisms like sum, append, and union. For example, the annotation (key=<Table-Name>) is used to indicate that the message should be stored in a particular indexed table like the Virtual Network table in the analytics database.
The sandesh code generator is used to transform the Sandesh IDL File (.sandesh) into source code, which is used by the generators. To generate the source from a sandesh file, user can run:
sandesh --gen <language> <sandesh filename>
For example, for a sandesh file – vns.sandesh, running sandesh –gen cpp vns.sandesh produces the following auto-generated C++ code:
vns_types.h, vns_types.cpp, vns_constants.h, vns_constants.cpp, vns_html.cpp, vns_html_template.cpp
vns_request_skeleton.cpp, vns.html, vns.xsl, vns.xml
style.css
Similarly, running sandesh –gen py vns.sandesh produces the gen_py and vns python packages. Following files are auto-generated in the vns package:
ttypes.py, constants.py, http_request.py, vns.xml, vns.xsl, vns.html, request_skeleton.py, style.css, index.html
The source code for the sandesh code generator can be accessed under the compiler/ directory.
Sandesh Types
Generators need to convey different types of information like system logs indicating occurrence of a system event, object state change information, statistics information, lightweight tracing needed for deep dive debugging, information to display current state of data structures. Developers can define different types of sandesh to address each of the above use cases.
1. systemlog
Use Case:
Structured log replacement for syslog.
Example:
systemlog sandesh BgpPeerTableMessageLog {
1: string PeerType;
2: "Peer"
3: string Peer;
4: "in table";
5: string Table;
6: ":";
7: string Message;
}
Notes:
systemlog can optionally have a (key=”<Table-Name”>) annotation and this can be used to corelate logs across different network elements. For example, a (key=”IPTable”) can be used to corelate logs pertaining to a specific IP address across the physical routers and the virtual routers / SDN control plane. The const static strings defined in the message above – elements 2, 4, and 6 are only used for display purposes when querying the logs from the analytics database.
2. objectlog
Use Case:
Logging state transitions and lifetime events for objects (VirtualMachine, VirtualNetwork). Objectlog is useful for performing historical state queries on an object. Objects have an object-id, which is indicated using the annotation (key=”<Object-TableName>”). For example, RoutingInstanceInfo below has name as the key.
Example:
struct RoutingInstanceInfo {
1: string name (key="ObjectRoutingInstance");
2: optional string route_distinguisher;
3: optional string operation;
4: optional string peer;
5: optional string family;
6: optional list<string> add_import_rt;
7: optional list<string> remove_import_rt;
8: optional list<string> add_export_rt;
9: optional list<string> remove_export_rt;
10: string hostname;
}
objectlog sandesh RoutingInstanceCollector {
1: RoutingInstanceInfo routing_instance;
}
Notes:
It is best practice to add the optional keyword to elements whose values do not change frequently and thus do not need to be sent with each message.
3. uve (User Visible Entities)
Use Case:
UVEs (User Visible Entities) are used represent the system-wide state of externally visible objects. uve is a special case of objectlog. UVEs are used to display the operational state of an object like VirtualMachine or VirtualNetwork, by aggregating information from uve sandesh messages across different generator types (configuration manager, virtual router, control node) and across nodes. uve like objectlog need the key annotation.
Details and Example:
For example, consider the VirtualNetwork uve sandesh definition. We specify its state in two “tiers” – configuration manager and virtual router. The configuration manager tier is defined in virtual_network.sandesh in the src/controller/config/uve directory and the virtual router tier is defined in virtual_network.sandesh in the src/controller/vnsw/agent/uve directory in the Juniper/contrail-controller Github repository. For each tier, we return a single structure, even though a given virtual network might be present on many software modules in that tier. A VirtualNetwork might be present on many virtual routers; these virtual routers are expected to send uve sandesh messages when any attribute of the VirtualNetwork changes state. The virtual router tier of the VirtualNetwork UVE definition looks like:
struct UveInterVnStats {
1: string other_vn (aggtype="listkey")
2: i64 out_tpkts;
3: i64 in_tpkts;
}
struct UveVirtualNetworkAgent {
1: string name(key="ObjectVNTable")
2: optional bool deleted
3: optional i32 total_acl_rules
4: optional i32 total_analyzers(aggtype=”sum”)
5: optional i64 in_tpkts (aggtype="counter")
7: optional i64 out_tpkts (aggtype="counter")
9: optional list<UveInterVnStats>stat(aggtype="append")
11: optional list<string> vm_list (aggtype="union")
}
uve sandesh UveVirtualNetworkAgentTrace {
1: UveVirtualNetworkAgent data;
}
UVEs are special case of Objectlog and hence each UVE has an object-id, which is denoted using the (key=”<Object-TableName>”) annotation. The annotation needs to consistent across all the tiers of the UVEs to allow correlation and aggregation to be performed by the analytics engine.
The “aggtype” annotation allows the developer to choose how the analytics engine should aggregate the attribute when sent across multiple generators and tiers. For example, for the “aggtype=sum” annotation on an attribute, the analytics engine reports an aggregate value that is a sum of the values sent by all generators. In the VirtualNetwork uve sandesh definition, each virtual router tracks the number of analyzer instances attached to a VirtualNetwork using the attribute “total_analyzers”. The aggregate value reported by the analytics engine should be a sum of the values of this attribute across all virtual routers on which the VirtualNetwork exists.
4. trace
Use Case:
Light-weight in memory buffer logs for frequently occurring events
Example:
trace sandesh XmppRxStream {
1: "Received xmpp message from: ";
2: string IPaddress;
3: "Port";
4: i32 port;
5: "Size: ";
6: i32 size;
7: "Packet: ";
8: string packet;
9: "$";
}
5. traceobject
Use Case:
Light-weight in memory buffer logs for frequently occurring object state transitions
Example:
traceobject sandesh RoutingInstanceCreate {
1: string name;
2: list<string> import_rt;
3: list<string> export_rt;
4: string virtual_network;
5: i32 index;
}
Notes about trace and traceobject:
Developer needs to create a Sandesh Trace Buffer with a given size wherein the trace and traceobject sandesh are stored. HTTP introspect (explained in the request and response sandesh) can be used to request viewing of the trace buffer. Tracing to the buffer can be enabled or disabled, and multiple types of trace and traceobject sandesh can be traced into a single trace buffer.
6. request and response
Use Case:
Request is used to send commands from requestor to generator. Response is used for response from generator to requestor. Request and response are used to dump internal data structures and provide operational information from the software modules needed for in-depth debugging.
Example:
request sandesh SandeshLoggingParamsSet {
1: bool enable;
2: string category;
3: string level;
}
response sandesh SandeshLoggingParams {
1: bool enable;
2: string category;
3: string level;
}
Notes:
The developer is expected to provide the implementation of the request handling function. For the above example, in C++ it will be implementation of SandeshLoggingParamsSet::HandleRequest function and for python a bound method named handle_request is expected to be present in SandeshLoggingParamsSet.
HTTP Introspect
Sandesh is also used to implement support for debugging in the OpenContrail controller and virtual router software modules. The debugging facility is called HTTP Introspect. The sandesh code generator produces HTML forms for each request sandesh and associated stylesheets that are required to render response sandesh when invoked with the –gen html option. Each software module contains an embedded web/HTTP server which developers can use to dump internal state of data structures, view trace messages, and perform other extensive debugging.
For example, to debug the BGP neighbor peering status on the control-node, the developer has defined a request sandesh in bgp_peer.sandesh as:
request sandesh BgpNeighborReq {
1: string ip_address;
2: string domain;
}
struct BgpNeighborResp {
1: string peer; // Peer name
2: string peer_address (link="BgpNeighborReq");
3: u32 peer_asn;
response sandesh BgpNeighborListResp {
1: list<BgpNeighborResp> neighbors;
}
To debug, developer can access the web page at http://<IP-Address of control-node>:8083/Snh_BgpNeighborReq?ip_address=&domain= using curl or the web browser and get the XML data corresponding to the response sandesh from the control-node.
The developers specify the commands supported by the web server (GETs) by defining a request sandesh. The data is returned in a response sandesh. The collector can also send a request sandesh and the response sandesh sent to the collector will be stored in the analytics database. Request and response sandesh thus provide a RESTful API to debugging the software modules.
Wrapping Up
Monitoring and running a multi-tenant data-center requires strong SDN analytics. Exposing the right network abstractions and having appropriate aggregation and syncing mechanisms are crucial for analytics to scale in massively distributed systems. The importance of open APIs cannot be understated in achieving the goal of SDN analytics to enable humans to cost-effectively monitor and operate a multi-tenant, multi-vendor data center.
Most modern network operating systems support C++, and Python, and by using Sandesh as the southbound interface, OpenContrail Analytics solution can be used to provide a consolidated view and deep insight across virtual and physical networks and events even in a multi-vendor environment. As the blog post illustrates, Sandesh is an open southbound interface and protocol that enables developers to expose the right abstractions and aggregation mechanisms required for SDN analytics. Integrating Sandesh on existing physical routers and switches in a multi-vendor environment is just a matter of defining the right abstractions and aggregation mechanisms in the IDL and using the back-end library. In future blog entries we will discuss the OpenContrail Analytics Engine aggregation and syncing mechanisms as well as the statistics collection mechanisms in detail.
|
__label__pos
| 0.982387 |
Emacs: Inconsistency of Search Features
By Xah Lee. Date: . Last updated: .
This page discuss inconsistency of the many emacs features related to text search (grep).
Emacs has many commands related to searching text. For example: {list-matching-lines, grep, rgrep, lgrep, grep-find, find-dired, dired-do-search, etc}. However, their interface are inconsistent. Their implementation is also inconsistent.
Interface Inconsistency
The interface isn't consistent. For example: grep and grep-find (with alias find-grep) both directly prompt you to enter unix command in one shot. But {find-dired, rgrep, lgrep} do several prompts asking for: {search string, file extension, directory}. (though, they still require user to be familiar with the unix commands. For example: When find-dired prompts “Run find (with args):”, you have to give -name "*html" or -type f etc.)
People who are not familiar unix won't be able to search a folder. The unix find/grep parameters are quite complex, and emacs documentation doesn't try to explain them.
Implementation Inconsistency
list-matching-lines (alias of occur) is implemented with elisp, while the others rely on unix utilities {grep, find}.
Calling external util has lots problems under Microsoft Windows. On Windows, external utilities may not be installed. Searching text is a critical feature of emacs. Then, there's Cygwin, MinGW and other variety issues. Emacs has to go thru several layers to interface with them.
On unix/linux including Mac OS X, BSD, there's also complex issues of identifying the version of grep/find used that differ in options and behavior. I recall that rgrep didn't work on Mac OS X around year 2007.
Then, emacs has to process the output to make syntax coloring. Also, if your search string contains Unicode, then there's complex problem about locale/encoding setup, environment variable setup and inheritance issues among the shell, the Operating System, and emacs.
[see Problems of grep in Emacs]
Suggestion: Unified Interface and Implemented in Emacs Lisp
It seems to me, they could all use elisp, with a single code engine, and with the same interface. The files to be searched can be from buffer list or dired marked files, or entered from prompt with emacs regex. The output can be a output like occur or can be dired list or buffer list. For example, you could have a command list-matching-lines, and then “list-matching-lines-directory” with options to do nested dirs, and options to use a pattern to filter files to search for, or options to get marked files in dired, and also options to show result as file list in dired.
These text searching task is what emacs lisp is designed to do, and is trivial to implement. It would eliminate the whole external program problems.
The core are already in emacs. occur, dired-do-query-replace-regexp, dired-do-search, and probably something in eshell too. They are just scattered and not unified.
Emacs Lisp Speed Issues?
Doing it inside elisp is not that slow. Slower than those written in C, but remember that emacs has to parse their output and the communication overhead might just make it up. I've written a grep command in elisp [see Emacs Lisp: Write grep]. Just tested now, calling it on a dir with subdir with total of 1592 files. Using a search word that returns over a thousand files. Both my script and unix util are close to 3 seconds. (For example, Alt+x shell in emacs, then give grep -c */*html) Calling grep -c */*html by shell-command is less than 1 second. Calling grep -c */*html by emacs's grep is about 3 seconds too.
(this article was originally posted to comp.emacs At http://groups.google.com/group/comp.emacs/browse_frm/thread/9458d26644fde3e4)
This report applies to GNU Emacs 24.0.93.1
Emacs Modernization
ErgoEmacs mascot-s276x226
Buy Xah Emacs Tutorial
|
__label__pos
| 0.850337 |
1
$\begingroup$
Find a power series in $x$ that has the given sum, and specify the radius of convergence.
$\frac{x^2+1}{x-1}$
$\frac{x^2+1}{x-1}=-(x^2+1)\frac{1}{1-x}$
$=-1-x-2 \sum_{2}^{\infty} x^n$
Now, is the radius of convergence will be changed if I delete the first two terms of the series?
I know that, delete the first 2 terms of the series has no effect on its convergence.
Since I can’t found the form of n-th term of the series with out delete the first two terms.
$lim_{n \to \infty} |\frac{a_{n+1}}{a_n}|= lim_{n \to \infty} |\frac{x^{n+1}}{x^n}|=|x|$.
By the ratio test, the series is convergent if $|x|<1$, so the radius of convergence is $r=1$
$\endgroup$
1 Answer 1
2
$\begingroup$
No, deleting the first two terms (or any finite amount of terms, for that matter) will not change the redius of convergence.
By the way, your answer is correct:$$\frac{x^2+1}{x-1}=-1-x-2\sum_{n=2}^\infty x^n.$$The radius of convergence of this power series is $1$.
$\endgroup$
3
• $\begingroup$ Thank you so much. For the radius of convergence, is that true please? (I edited my question). $\endgroup$
– Dima
Commented Oct 31, 2018 at 19:38
• $\begingroup$ Yes, your argument is correct $\endgroup$ Commented Oct 31, 2018 at 19:55
• $\begingroup$ Thank you so much. $\endgroup$
– Dima
Commented Oct 31, 2018 at 19:58
You must log in to answer this question.
Not the answer you're looking for? Browse other questions tagged .
|
__label__pos
| 0.983343 |
Jeff PHP framework 0.99
Modular, extensible, OOP, MVC, lightweight php framework designed to ease the programmers in the development of web applications.
captcha.class.php
Go to the documentation of this file.
00001 <?php
00021 class captcha {
00022
00026 private $_name;
00027
00031 private $_width;
00032
00036 private $_height;
00037
00041 private $_font_file;
00042
00046 private $_letters;
00047
00051 private $_numbers;
00052
00056 private $_allow_numbers;
00057
00067 function __construct($name, $opts=null) {
00068
00069 $this->_name = $name;
00070 $this->_width = 200;
00071 $this->_height = 40;
00072
00073 $this->_font_file = ABS_ROOT.DS.'font'.DS.'initial.ttf';
00074
00075 $this->_letters = array("a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z");
00076 $this->_numbers = array("0", "1", "2", "3", "4", "5", "6", "7", "8", "9");
00077
00078 $this->_allow_numbers = gOpt($opts, 'allow_numbers', false);;
00079
00080 }
00081
00091 public function render($opts=null) {
00092
00093 $bkg_color = gOpt($opts, "bkg_color", "#00ff00");
00094 $color = gOpt($opts, "color", "#000000");
00095
00096 $image = ImageCreatetruecolor($this->_width, $this->_height);
00097
00098 // background
00099 $bcs = $this->hex2RGB($bkg_color);
00100 $bkg_c = ImageColorAllocate($image, $bcs['red'], $bcs['green'], $bcs['blue']);
00101 imagefill($image, 0, 0, $bkg_c);
00102
00103 // text
00104 $tcs = $this->hex2RGB($color);
00105 $text_c = ImageColorAllocate($image, $tcs['red'], $tcs['green'], $tcs['blue']);
00106 list($s1, $s2) = $this->generateStrings();
00107 imagettftext($image, 22, 2, 5, $this->_height-5, ImageColorAllocate($image, 0, 0, 0), $this->_font_file, $s1);
00108 imagettftext($image, 22, -5, 110, 25, ImageColorAllocate($image, 0, 0, 0), $this->_font_file, $s2);
00109
00110 // ellipses
00111 $i = 0;
00112 while($i<$this->_width-5) {
00113 $ell_color = ImageColorAllocate($image, rand(0,255), rand(0,255), rand(0,255));
00114 imagefilledellipse($image , $i+5 , rand(5, $this->_height-5) , rand(0, 8) , rand(0, 8), $ell_color);
00115 $i = $i+20;
00116 }
00117
00118 // lines
00119 $i = 0;
00120 while($i<$this->_width-3) {
00121 $line_color = ImageColorAllocate($image, rand(0,255), rand(0,255), rand(0,255));
00122 imagesetthickness($image, rand(0,2));
00123 imageline($image, $i , rand(0, $this->_height) , rand($i, $i+20) , rand(0, $this->_height) , $line_color);
00124 $i = $i+10;
00125 }
00126
00127 ob_start();
00128 imagejpeg($image);
00129 imagedestroy($image);
00130 $img = ob_get_contents();
00131 ob_end_clean();
00132
00133 $_SESSION['captcha_code'] = $s1.$s2;
00134
00135 $buffer = "<img src=\"data:image/jpeg;base64,".base64_encode($img)."\" /><br />";
00136 $buffer .= "<input name=\"$this->_name\" type=\"text\" size=\"10\" maxlength=\"20\" required=\"required\" />";
00137
00138 return $buffer;
00139
00140 }
00141
00147 private function generateStrings() {
00148
00149 $s1 = $s2 = '';
00150
00151 $coin = rand(0,10) < 5 ? true : false;
00152
00153 $ls1 = $coin ? 5 : 4;
00154 $ls2 = $coin ? 4 : 5;
00155
00156 for($i=0; $i<$ls1; $i++) {
00157 $coin = $this->_allow_numbers ? rand(0, 10) : 0;
00158 $s1 .= $coin < 5 ? $this->_letters[array_rand($this->_letters)] : $this->_numbers[array_rand($this->_numbers)];
00159 }
00160
00161 for($i=0; $i<$ls2; $i++) {
00162 $coin = $this->_allow_numbers ? rand(0, 10) : 0;
00163 $s2 .= $coin < 5 ? $this->_letters[array_rand($this->_letters)] : $this->_numbers[array_rand($this->_numbers)];
00164 }
00165
00166 return array($s1, $s2);
00167
00168 }
00169
00176 private function hex2RGB($hexStr) {
00177
00178 $hexStr = preg_replace("/[^0-9A-Fa-f]/", '', $hexStr); // Gets a proper hex string
00179 $rgbArray = array();
00180
00181 if (strlen($hexStr) == 6) { //If a proper hex code, convert using bitwise operation. No overhead... faster
00182 $colorVal = hexdec($hexStr);
00183 $rgbArray['red'] = 0xFF & ($colorVal >> 0x10);
00184 $rgbArray['green'] = 0xFF & ($colorVal >> 0x8);
00185 $rgbArray['blue'] = 0xFF & $colorVal;
00186 }
00187 elseif (strlen($hexStr) == 3) { //if shorthand notation, need some string manipulations
00188 $rgbArray['red'] = hexdec(str_repeat(substr($hexStr, 0, 1), 2));
00189 $rgbArray['green'] = hexdec(str_repeat(substr($hexStr, 1, 1), 2));
00190 $rgbArray['blue'] = hexdec(str_repeat(substr($hexStr, 2, 1), 2));
00191 }
00192 else {
00193 return false; //Invalid hex color code
00194
00195 }
00196
00197 return $rgbArray; // returns the rgb string or the associative array
00198 }
00199
00205 public function check() {
00206
00207 $string = preg_replace("#[ \s]#", "", $_POST[$this->_name]);
00208
00209 if(!$string) return false;
00210
00211 $result = $string === $_SESSION['captcha_code'] ? true : false;
00212
00213 unset($_SESSION['captcha_code']);
00214
00215 return $result;
00216
00217 }
00218
00219 }
00220
00221 ?>
|
__label__pos
| 0.674187 |
Форум 1С
Программистам, бухгалтерам, администраторам, пользователям
Задай вопрос - получи решение проблемы
26 сен 2021, 06:29
Получить картинку из хранилища значения
Автор xordax24, 03 июл 2017, 15:36
0 Пользователей и 1 гость просматривают эту тему.
xordax24
Добрый день!
Помогите разобраться, пожалуйста!
У меня есть справочник Пользователи с реквизитом Картинка, который ссылается на справочник Файлы2. Справочник Файлы2 содержит реквизит Файл с типом Хранилище значения, где и хранится картинка. Так вот как получить изображение соответствующее определенному элементу справочника Пользователи.Наименование?
Я пыталась получить с помощью запроса:
Запрос = Новый Запрос;
Запрос.Текст = "ВЫБРАТЬ
| Пользователи.Наименование,
| Файлы2.Файл
|ИЗ
| Справочник.Пользователи КАК Пользователи
| ЛЕВОЕ СОЕДИНЕНИЕ Справочник.Файлы2 КАК Файлы2
| ПО Пользователи.Картинка = Файлы2.Ссылка
|ГДЕ
| Пользователи.Наименование = &Ответственный" ;
РезультатПоиска = Справочники.Пользователи.НайтиПоНаименованию(Ссылка.Ответственный);
Запрос.УстановитьПараметр("&Ответственный", РезультатПоиска);
РезультатЗапроса = Запрос.Выполнить();
ВыборкаДетальныеЗаписи = РезультатЗапроса.Выбрать();
Но в итоге ВыборкаДетальныеЗаписи имеет значение Ошибка чтения записи.
ilyay
Для управляемой формы:
Нужна навигационная ссылка на хранилище, которую присваиваете в строковую переменную, а эту переменная выводится на форме. А из хранилища данные достаются так: Выборка.Хранилище.Получить().
Но вам нужны не сами двоичные данные, а навигационная ссылка. Либо сразу на реквизит в базе, либо получаете двоичное значение и помещаете во временное хранилище с указанием уникального идентификатора формы. Адрес временного хранилища - то, что вам надо поместить в строковую переменную
Dethmontt
Заменить
|ГДЕ
| Пользователи.Наименование = &Ответственный" ;
на
|ГДЕ
| Пользователи.ссылка = &Ответственный" ;
Если долго всматриваться в учебник...то в голову может прийти мысль его открыть!
xordax24
Цитата: Dethmontt от 03 июл 2017, 17:53
Заменить
|ГДЕ
| Пользователи.Наименование = &Ответственный" ;
на
|ГДЕ
| Пользователи.ссылка = &Ответственный" ;
Ох, спасибо добрый человек! :zebzdr:
Теги: выборка
Похожие темы (5)
Рейтинг@Mail.ru Rambler's Top100
Поиск
|
__label__pos
| 0.685522 |
Browse Source
Notification on errors while sending message
Fixed Location messages
Updated config example
Updated README
master
annelin 5 months ago
parent
commit
d1f58a02dc
3 changed files with 30 additions and 25 deletions
1. 15
10
README.md
2. 13
13
config.yml.example
3. 2
2
inc/telegramclient.rb
+ 15
- 10
README.md View File
@@ -31,13 +31,13 @@ Next, rename **config.yml.example** to **config.yml** and edit **xmpp** section
```
xmpp:
db_path: 'users.db'
:xmpp:
db 'users.db'
jid: 'tlgrm.localhost'
host: 'localhost'
port: 8888
secret: 'secret'
loglevel: 0
loglevel: :warn
```
### Configuration ###
@@ -45,9 +45,12 @@ xmpp:
It is good idea to obtain Telegram API ID from [**https://my.telegram.org**](https://my.telegram.org) to remove demo key requests limit, and then edit in **config.yml**:
```
telegram:
api_id: '845316' # telegram API ID (my.telegram.org) #
api_hash: '27fe5224bc822bf3a45e015b4f9dfdb7' # telegram API HASH (my.telegram.org) #
:telegram:
:tdlib:
:lib_path: 'lib/'
:client:
:api_id: '845316' # telegram API ID (my.telegram.org) #
:api_hash: '27fe5224bc822bf3a45e015b4f9dfdb7' # telegram API HASH (my.telegram.org) #
...
```
@@ -66,10 +69,10 @@ server {
}
```
You need to set `content_path` and `content_link` in **config.yml**.
You need to set `:content: → :path: and :link:` **config.yml**.
Set `content_path` according to location (for our example it will be `/var/zhabogram/content`).
Set `content_link` according to server_name (for our example it will be `http://tlgrm.localhost`)
Set `:path:` according to location (for our example it will be `/var/zhabogram/content`).
Set `:link:` according to server_name (for our example it will be `http://tlgrm.localhost`)
### How to send files to Telegram chats ###
@@ -93,7 +96,7 @@ modules:
Then you need to setup nginx proxy that will serve `get_url` path, because Telegram will not handle URLs with non-default http(s) ports.
Example nginx config:
```
/```
server {
listen 80;
listen 443 ssl;
@@ -115,3 +118,5 @@ server {
}
```
Finally, update `:upload:` in your config.yml to match `server_name` in nginx config.
+ 13
- 13
config.yml.example View File
@@ -1,23 +1,23 @@
:telegram:
:lib_path: 'lib/'
:verbosity: 1
:loglevel: :warn
:client:
:api_id: '17349'
:api_hash: '344583e45741c457fe1862106095a5eb'
:device_model: 'zhabogram'
:application_version: '2.0'
:use_chat_info_database: false
:content:
:path: '/var/www/zhabogram/media' # webserver workdir
:link: 'http://localhost/zhabogram/media' # webserver public address
:upload: 'https://localhost/upload' # xmpp http upload address
:path: '/var/www/zhabogram/content' # webserver workdir
:link: 'http://tlgrm.localhost/content' # webserver public address
:upload: 'https:///xmppfiles.localhost' # xmpp http upload address
:tdlib_verbosity: 1
:tdlib:
:lib_path: 'lib/'
:client:
:api_id: '17349'
:api_hash: '344583e45741c457fe1862106095a5eb'
:device_model: 'zhabogram'
:application_version: '2.0'
:use_chat_info_database: false
:xmpp:
:debug: false
:loglevel: :warn
:jid: 'tlgrm.localhost'
:host: '127.0.0.1'
:port: 8899
:jid: 'tlgrm.localhost'
:password: 'password'
:db: 'sessions.dat'
+ 2
- 2
inc/telegramclient.rb View File
@@ -126,7 +126,7 @@ class TelegramClient
when TD::Types::MessageContent::ChatDeleteMember then "kicked %s" % self.format_contact(update.message.content.user_id)
when TD::Types::MessageContent::PinMessage then "pinned message: %s" % self.format_message(update.message.chat_id, content.message_id)
when TD::Types::MessageContent::ChatChangeTitle then "chat title set to: %s" % update.message.content.title
when TD::Types::MessageContent::Location then "coordinates: %s | https://www.google.com/maps/search/%s,%s/" % [content.location.latitude, content.location.longitude]
when TD::Types::MessageContent::Location then "coordinates: %{latitude},%{longitude} | https://www.google.com/maps/search/%{latitude},%{longitude}/" % content.location.to_h
when TD::Types::MessageContent::Photo, TD::Types::MessageContent::Audio, TD::Types::MessageContent::Video, TD::Types::MessageContent::Document then content.caption.text
when TD::Types::MessageContent::Text then content.text.text
when TD::Types::MessageContent::VoiceNote then content.caption.text
@@ -241,7 +241,7 @@ class TelegramClient
text = TD::Types::FormattedText.new(text: (reply or file) ? text.lines[1..-1].join : text, entities: []) # remove first line from text
message = TD::Types::InputMessageContent::Text.new(text: text, disable_web_page_preview: false, clear_draft: false) # compile our message
document = TD::Types::InputMessageContent::Document.new(document: file, caption: text) if file # we can try to send a document
message_id ? @telegram.edit_message_text(chat_id, message_id, message) : @telegram.send_message(chat_id, document || message, reply_to_message_id: reply || 0).rescue{@telegram.send_message(chat_id, message, 0)}
message_id ? @telegram.edit_message_text(chat_id, message_id, message) : @telegram.send_message(chat_id,document||message, reply_to_message_id: reply||0).rescue{|why| @xmpp.send_message(@jid, chat_id,"Message not sent: %s" % why)}
end
## /commands (some telegram actions)
Loading…
Cancel
Save
|
__label__pos
| 0.984965 |
PDA
View Full Version : Cool Header help
GhettoT
11-25-2006, 08:11 PM
Is it possible to say, on rollover change image to ___, on browser load change image to ____, or on browser load show image ____ wait 3seconds change image to ___? You see, I am the webmaster of a site, and I am only able to use open source or donated products and i want to do a flash intro type header but without flash, just HTML and javascript. Anyone know how to accomplish this? Or know of a free flash type software?
-GT
Twey
11-25-2006, 09:20 PM
<script type="text/javascript">
function preloadImages() {
for(var i = 0; i < arguments.length; ++i)
(preloadImages.store[preloadImages.store.length] = new Image()).src = arguments[i];
}
preloadImages.store = [];
preloadImages("/path/to/loaded_image.png", "/path/to/mouseover_image.png", "/path/to/timed_image.png");
window.onload = function() {
var e = document.images['header_image'];
e.src = preloadImages.store[0].src;
e.onmouseover = function() {
this.src = preloadImages.store[1].src;
};
e.onmouseout = function() {
this.src = preloadImages.store[0].src;
};
window.setTimeout(
function() {
document.images['header_image'].src = preloadImages.store[2].src;
},
3000
);
e = null;
};
</script>
</head>
<body>
<h1>
<img src="/path/to/initial_image.png" id="header_image" alt="Header Text">
</h1>
GhettoT
11-25-2006, 10:48 PM
thanks. that is for the load image to different image right?
-GT
Twey
11-25-2006, 10:54 PM
It does all three. Just replace the URLs to the images and off you go.
GhettoT
11-26-2006, 12:25 AM
Awesome thanks!
GhettoT
11-26-2006, 12:53 AM
Sorry to bug/double post, but how would you add fade out/fade in effects to this setup? Would it be something like this?
<SCRIPT LANGUAGE="JavaScript">
<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->
<!-- Begin
var maximages = 6; // how many fade images do you have?
var fadespeed = 125; // fade frame time in milliseconds; 125 = 125 ms
var fadeintimer;
var fadeouttimer;
var fadeincount = 0;
var fadeoutcount = maximages-1;
var fadearray = new Array(maximages); // enter all the fade images here
// the first item should be 0, then numbered through 1 less than your maximages
fadearray[0] = "http://javascript.internet.com/img/fading-rollover/fade00.jpg";
fadearray[1] = "http://javascript.internet.com/img/fading-rollover/fade01.jpg";
fadearray[2] = "http://javascript.internet.com/img/fading-rollover/fade02.jpg";
fadearray[3] = "http://javascript.internet.com/img/fading-rollover/fade03.jpg";
fadearray[4] = "http://javascript.internet.com/img/fading-rollover/fade04.jpg";
fadearray[5] = "http://javascript.internet.com/img/fading-rollover/fade05.jpg";
for (var i = 0; i < maximages; i++) {
eval('pic' + i + ' = new Image();');
eval('pic' + i + '.src = fadearray[i];'); // preloads fade images
}
function fade_in() {
clearTimeout(fadeouttimer);
document.images['fade-pic'].src = fadearray[fadeincount];
if (fadeincount != maximages-1) {
fadeincount++;
fadeintimer = setTimeout('fade_in()', fadespeed);
}
else {
clearTimeout(fadeintimer);
fadeincount = 0;
}
}
function fade_out() {
clearTimeout(fadeintimer);
document.images['fade-pic'].src = fadearray[fadeoutcount];
if (fadeoutcount != 0) {
fadeoutcount--;
fadeouttimer = setTimeout('fade_out()', fadespeed);
}
else {
clearTimeout(fadeouttimer);
fadeoutcount = maximages-1;
}
}
// End -->
</script>
</HEAD>
<BODY>
<center>
<a href="http://javascriptsource.com" onmouseover="fade_in()" onmouseout="fade_out()">
<img src="http://javascript.internet.com/img/fading-rollover/icontop.gif" border=0><br>
<img name="fade-pic" height=56 width=300 border=0 src="http://javascript.internet.com/img/fading-rollover/fade00.jpg"><br>
<img src="http://javascript.internet.com/img/fading-rollover/iconbtm.gif" border=0><br></a>
</center>
I am sort of new to javascript, so please excuse my lack of knowledge...Also, i realize with the setup i just posted, it is more of a "Splash" type intro, but is it possible to have just 2 images? One just the image the other the image with the whatever added?
-GT
Twey
11-26-2006, 01:28 AM
It's not going to be easy. Fading elements in and out is fairly simple, but fading one into another means positioning one exactly over the top of the other. It would be easier to fade it out, change the src, then fade it back. Is this sufficient.
GhettoT
11-26-2006, 02:19 AM
I guess. I'm not too sure what you mean though... I just meant for the onload to after 3 seconds header part. Because like i said before, it is supposed to be similar to that of a flash intro, then it stays on that second image until the mouseover where it returns to the original picture.
-GT
Twey
11-26-2006, 01:06 PM
<script type="text/javascript" src="http://www.twey.co.uk/includes/FadableObject.js"></script>
<script type="text/javascript">
function preloadImages() {
for(var i = 0; i < arguments.length; ++i)
(preloadImages.store[preloadImages.store.length] = new Image()).src = arguments[i];
}
preloadImages.store = [];
preloadImages("/path/to/loaded_image.png", "/path/to/mouseover_image.png", "/path/to/timed_image.png");
window.onload = function() {
var e = document.images['header_image'];
new FadableObject(e, 1, 10, 0, 99, false, false);
e.src = preloadImages.store[0].src;
e.onmouseover = function() {
this.fadeThread.fadeOut(function(){
this.element.src = preloadImages.store[1].src;
this.fadeIn();
});
};
e.onmouseout = function() {
function() {
document.images['header_image'].fadeThread.fadeOut(function(){
this.element.src = preloadImages.store[0].src;
this.fadeIn();
});
};
window.setTimeout(
function() {
document.images['header_image'].fadeThread.fadeOut(function(){
this.element.src = preloadImages.store[2].src;
this.fadeIn();
});
},
3000
);
e = null;
};
</script>
</head>
<body>
<h1>
<img src="/path/to/initial_image.png" id="header_image" alt="Header Text">
</h1>
GhettoT
11-26-2006, 07:35 PM
Thanks for all your help Twey! I will be sure to put in the source in comments a plug for you and your site! But do i just throw all of that into the <head> section? Do i need to put anything in the <body>?
-GT
Twey
11-26-2006, 07:41 PM
The code includes a </head> and <body> :)
GhettoT
11-26-2006, 08:34 PM
wow...sorry i am dumb i saw it before and didn't even think about it! Thanks again! I'll try not to bug anymore, and try to fresh'n up my javascript skills!
GhettoT
12-02-2006, 02:14 AM
Just another thought i had to make this cool idea abailable to everyone using any browser. Is it possible to take care of this idea using CSS, HTML, and minimal Javascript?
-GT
Twey
12-02-2006, 02:51 AM
Presuming you intend "minimal Javascript" to mean "little enough Javascript that it will still work for non-Javascript users," no, or I would have done it that way :)
GhettoT
12-02-2006, 04:54 AM
OK that makes sense. Now back to the original script you actually made. I finally was able to add it to my HTML document, but as I am a code neat freak I did a setup like such.
HTML Document:
<body>
<div align="center"><script type="text/javascript" src="header.js"></div>
........
</body>
</HTML>
The "header.js" looks like:
<script type="text/javascript" src="fadableobjects.js"></script>
function preloadImages() {
for(var i = 0; i < arguments.length; ++i)
(preloadImages.store[preloadImages.store.length] = new Image()).src = arguments[i];
}
preloadImages.store = [];
preloadImages("/path/to/loaded_image.png", "/path/to/mouseover_image.png", "/path/to/timed_image.png");
window.onload = function() {
var e = document.images['header_image'];
new FadableObject(e, 1, 10, 0, 99, false, false);
e.src = preloadImages.store[0].src;
e.onmouseover = function() {
this.fadeThread.fadeOut(function(){
this.element.src = preloadImages.store[1].src;
this.fadeIn();
});
};
e.onmouseout = function() {
function() {
document.images['header_image'].fadeThread.fadeOut(function(){
this.element.src = preloadImages.store[0].src;
this.fadeIn();
});
};
window.setTimeout(
function() {
document.images['header_image'].fadeThread.fadeOut(function(){
this.element.src = preloadImages.store[2].src;
this.fadeIn();
});
},
3000
);
e = null;
};
}
Notice I added a "}" at the end of the document. With this setup, why does the header not even show up in my page? And when I use a debug add-in called "FireBug" for FireFox, why do i keep getting an error that says, "FadableObject is not defined"? Is it not defined because that var. is defined on the page located on your site?
-GT
GhettoT
12-02-2006, 07:15 AM
OK, i spent some time debugging myself, and trying to understand all of the javascript written by Twey and gotit to work! This is how i did it:
HTML:
<head>
<script type="text/javascript" src="fadableobjects.js">
</script>
<script type="text/javascript" src="header.js">
<!-- header.js is the script writtenby Twey here in this thread -->
</script>
</head>
.......
<body>
<h1>
<div align="center"><img src="PATH/TO/IMAGE.png" id="header_image" alt="Team 330"></div>
</h1>
Twey
12-02-2006, 02:01 PM
It was very simple:
<script type="text/javascript" src="fadableobjects.js"></script>You left this script tag in the Javascript file. Only Javascript is allowed in a Javascript file; that's HTML.
Notice I added a "}" at the end of the document.It's unnecessary, and will cause an error.
I am a code neat freakYet:
</body>
</HTML>your indentation is somewhat messed up and you're mixing tag cases? :p
GhettoT
12-02-2006, 07:44 PM
The "}" actually fixed an error i was getting.
Twey
12-02-2006, 08:13 PM
Hm... that's peculiar. There's no extraneous "{" in there that I can see.
GhettoT
12-02-2006, 09:18 PM
Without it the fade-out doesn't work and i get an error that says
missing } after function body header.js line 39 Line 39 doesn't excist so it is looking for the }
Twey
12-03-2006, 01:58 AM
Aha -- I see the problem. It should look like this:
function preloadImages() {
for(var i = 0; i < arguments.length; ++i)
(preloadImages.store[preloadImages.store.length] = new Image()).src = arguments[i];
}
preloadImages.store = [];
preloadImages("/path/to/loaded_image.png", "/path/to/mouseover_image.png", "/path/to/timed_image.png");
window.onload = function() {
var e = document.images['header_image'];
new FadableObject(e, 1, 10, 0, 99, false, false);
e.src = preloadImages.store[0].src;
e.onmouseover = function() {
this.fadeThread.fadeOut(function(){
this.element.src = preloadImages.store[1].src;
this.fadeIn();
});
};
e.onmouseout = function() {
document.images['header_image'].fadeThread.fadeOut(function(){
this.element.src = preloadImages.store[0].src;
this.fadeIn();
});
};
window.setTimeout(
function() {
document.images['header_image'].fadeThread.fadeOut(function(){
this.element.src = preloadImages.store[2].src;
this.fadeIn();
});
},
3000
);
e = null;
};There was an extra "function() {" for some reason.
|
__label__pos
| 0.877991 |
irc irc - 4 months ago 9
Python Question
Regex to strip only start of string
I am trying to match phone number using regex by stripping unwanted prefixes like 0, *, # and +
e.g.
+*#+0#01231340010
should produce,
1231340010
I am using python re module
I tried following,
re.sub(r'[0*#+]', '', '+*#+0#01231340010')
but it is removing later 0s too.
I tried to use regex groups, but still it's not working ( or I am doing something wrong for sure ).
Any help will be appreciated.
Thanks in advance.
Answer
Add the start of the string check (^) and * quantifier (0 or more occurences):
>>> re.sub(r'^[0*#+]*', '', '+*#+0#01231340010')
'1231340010'
Or, a non-regex approach using itertools.dropwhile():
>>> from itertools import dropwhile
>>> not_allowed = {'0', '*', '#', '+'}
>>> ''.join(dropwhile(lambda x: x in not_allowed, s))
'1231340010'
Comments
|
__label__pos
| 0.758346 |
Additional Blogs by Members
cancel
Showing results for
Search instead for
Did you mean:
Former Member
2,160
What is Easy Query and why is it important for SAP BPC?
Easy queries allow external access to BEX queries via different methods such as service or function module.
It is quite important for SAP BPC, because in most cases forecast data or plan data is highly dependent on the actual data like accruals , ending inventory, some KPI's, drivers or ratios that would be used in SAP BPC business logic and calculations.
In one of my customer , some calculations are based on value of a column of complex bex query. That's why it is not a solution of transferring data from actual data infoprovider to BPC model. Since business logic that was applied on SAP BEX query is needed to be replicated and hard to maintain afterwards . So i decided to use easy query approach because it will provide SAP BEX Query as a function module(SM37) that can be easily consumed in SAP BPC custom logic calculations using ABAP.
You can also check following blog entry Easy queries on SAP NetWeaver BW to understand details of easy query.
Step to Configure Easy Query
You can follow the step here in SAP Documentation Configuring Easy Queries - Configuration - SAP Library or alternatively you can follow the instructions for automatic setup in SAP OSS note : 1944258 - Easy query setup: Setup-Report .
For reference i will also include configuration steps here.
1. use transaction SBGRFCCONF to congifure bgRFC .
2. According to SAP Documentation use following Inb. Destination name and Prefix .
3. Be sure , service is activated on SICF.( WDA_EQ_Manager )
3. After configuration is setup up , create a BEX query and on the extended query properties click the Easy Query.
Please keep in mind there are some limitations of easy query ( ex: chars on row and key figures on column , single value variables etc).
4. then use EQManager transaction so see the details of easy query . On the function module column , you can see the function module which you can use in your ABAP calls. ( /BIC/NF_1 in our example )
5. then you can call this function in SM37. You can also use variables in you bex query and they are represented import parameters here in function module.
Finally, you can see the bex query result in a tabular format which is easy integrated in your SAP BPC custom logic using ABAP.
Hope it helps you in your BPC scenarios.
regards
Baris C.
|
__label__pos
| 0.891937 |
Fandom
Psychology Wiki
Normalizing constant
34,202pages on
this wiki
Add New Page
Add New Page Talk0
The concept of a normalizing constant arises in probability theory and a variety of other areas of mathematics.
Definition and examplesEdit
In probability theory, a normalizing constant is a constant by which an everywhere nonnegative function must be multiplied in order that the area under its graph is 1, i.e., to make it a probability density function or a probability mass function.[1][2] For example, we have
\int_{-\infty}^\infty e^{-x^2/2}\,dx=\sqrt{2\pi\,},
so that
\varphi(x) = \frac{1}{\sqrt{2\pi\,}} e^{-x^2/2}
is a probability density function.[3] This is the density of the standard normal distribution. (Standard, in this case, means the expected value is 0 and the variance is 1.)
Similarly,
\sum_{n=0}^\infty \frac{\lambda^n}{n!}=e^\lambda ,
and consequently
f(n)=\frac{\lambda^n e^{-\lambda}}{n!}
is a probability mass function on the set of all nonnegative integers.[4] This is the probability mass function of the Poisson distribution with expected value λ.
Note that if the probability density function is a function of various parameters, so too will be its normalizing constant. The parametrised normalizing constant for the Boltzmann distribution plays a central role in statistical mechanics. In that context, the normalizing constant is called the partition function.
Bayes' theoremEdit
Bayes' theorem says that the posterior probability measure is proportional to the product of the prior probability measure and the likelihood function . Proportional to implies that one must multiply or divide by a normalizing constant in order to assign measure 1 to the whole space, i.e., to get a probability measure. In a simple discrete case we have
P(H_0|D) = \frac{P(D|H_0)P(H_0)}{P(D)}
where P(H0) is the prior probability that the hypothesis is true; P(D|H0) is the conditional probability of the data given that the hypothesis is true, but given that the data are known it is the likelihood of the hypothesis (or its parameters) given the data; P(H0|D) is the posterior probability that the hypothesis is true given the data. P(D) should be the probability of producing the data, but on its own is difficult to calculate, so an alternative way to describe this relationship is as one of proportionality:
P(H_0|D) \sim P(D|H_0)P(H_0).
Since P(H|D) is a probability, the sum over all possible (mutually exclusive) hypotheses should be 1, leading to the conclusion that
P(H_0|D) = \frac{P(D|H_0)P(H_0)}{\sum_i P(D|H_i)P(H_i)} .
In this case, the reciprocal of the value
P(D)=\sum_i P(D|H_i)P(H_i) \;
is the normalizing constant.[5] It can be extended from countably many hypotheses to uncountably many by replacing the sum by an integral.
Non-probabilistic usesEdit
The Legendre polynomials are characterized by orthogonality with respect to the uniform measure on the interval [− 1, 1] and the fact that they are normalized so that their value at 1 is 1. The constant by which one multiplies a polynomial in order that its value at 1 will be 1 is a normalizing constant.
Orthonormal functions are normalized such that
\langle f_i , \, f_j\rangle = \, \delta_{i,j}
with respect to some inner product <fg>.
The constant 1/√2 is used to establish the hyperbolic functions cosh and sinh from the lengths of the adjacent and opposite sides of a hyperbolic triangle.
NotesEdit
1. Continuous Distributions at University of Alabama.
2. Feller, 1968, p. 22.
3. Feller, 1968, p. 174.
4. Feller, 1968, p. 156.
5. Feller, 1968, p. 124.
ReferencesEdit
• Continuous Distributions at Department of Mathematical Sciences: University of Alabama in Huntsville
• Feller, William (1968). An Introduction to Probability Theory and its Applications (volume I), John Wiley & Sons.
Also on Fandom
Random Wiki
|
__label__pos
| 0.99605 |
How do you use limits to find the area between the curve #y=x^4# and the x axis from [0,5]?
Answer 1
#625#
With limits you say... Ok.
Imaging we have some function #f(x)# and we want to find the area underneath it in the interval #[a, b]#. We first start by dividing the area into tiny rectangles like so:
This means the height of each rectangle is equal to the value of the function at that point. Refer to #R_1#. The height of #R_1# is equal to #f(x_0)#, and the area of it is equal to #f(x_0)Delta x# where #Delta x# is just the constant width of each rectangle.
Therefore the area under #[a, b]# is in the diagram above is:
#sum_(n=0)^N R_n=sum_(n=0)^N f(a+nDeltax) Deltax=Deltax sum_(n=0)^N f(a+nDeltax)#
Where #N=(|a-b|)/(Deltax)#
We would also say that for smaller and smaller values of #Delta x#, our approximation of the area will become better and better. Sound familiar? Let's use a limit!
#Area=lim_(Delta x -> 0) sum_(n=0)^N f(a+nDeltax) Deltax#
Now that is some ugly stuff. Let's simplify this a bit and that advantage that the interval you want to find is #[0, 5]# which starts at #0# obviously:
#Area=lim_(Delta x -> 0) sum_(n=0)^N f(nDeltax) Deltax#
Another way of describing #Delta x# is #(|a-b|)/N# (see above equations). So, in this case, it's #(|a-b|)/N#. Since we are applying the limit, there's no need for this to be intuitive and we can go ahead and say: #lim_(N -> oo)#
Finally:
#Area=lim_(N -> oo) sum_(n=1)^N f(5/Nn) 5/N#
Oh, did I mention that #n=0# and #n=1# won't matter, but let's make it #1# for the sake of calculations. And there we have it folks, our very own limit for an area.
To do anything with it, we need to expand stuff. Starting with #f(x)# and then factoring out any things that can be factored:
#lim_(N -> oo) sum_(n=1)^N f(5/Nn) 5/N=lim_(N -> oo) 5/N sum_(n=1)^N (5/N)^4n^4#
#=lim_(N -> oo) 5^5/N^5 sum_(n=1)^N n^4#
And we need to expand out the summation:
#sum_(n=1)^N n^4=(1/5)n^5 + (1/2)n^4 + (1/3)n^3 - (1/30)n#
#lim_(N -> oo) 5^5/N^5 sum_(n=1)^N n^4#
#=5^5 * 1/5 + 0#
#=625#
Sign up to view the whole answer
By signing up, you agree to our Terms of Service and Privacy Policy
Sign up with email
Answer 2
See below.
One of the possible realizations for that integral in terms of Riemann sum is
#lim_(n->oo)sum_(k=0)^(k=n) ((5k)/n)^4(5/n)#
we have
#lim_(n->oo)sum_(k=0)^(k=n) ((5k)/n)^4(5/n)=625#
Sign up to view the whole answer
By signing up, you agree to our Terms of Service and Privacy Policy
Sign up with email
Answer 3
#625#
It is better to integrate than to use limits in the problem:
#int_0^5[x^4]dx=x^5/5=5^4=625#
Sign up to view the whole answer
By signing up, you agree to our Terms of Service and Privacy Policy
Sign up with email
Answer 4
# int_0^5 \ x^4 \ dx = 625#
By definition of an integral, then
# int_a^b \ f(x) \ dx #
represents the area under the curve #y=f(x)# between #x=a# and #x=b#. We can estimate this area under the curve using thin rectangles. The more rectangles we use, the better the approximation gets, and calculus deals with the infinite limit of a finite series of infinitesimally thin rectangles.
That is
# int_a^b \ f(x) \ dx = lim_(n rarr oo) (b-a)/n sum_(i=1)^n \ f(a + i(b-a)/n)#
Here we have #f(x)=x^4# and we partition the interval #[0,5]# using:
# Delta = {0, 0+1*5/n, 0+2*5/n, ..., 0+n*5/n } # # \ \ \ = {0, 5/n, 2*5/n, ..., 5 } #
And so:
# I = int_0^5 \ x^4 \ dx # # \ \ = lim_(n rarr oo) 5/n sum_(i=1)^n \ f(0+i*5/n)# # \ \ = lim_(n rarr oo) 5/n sum_(i=1)^n \ f((5i)/n)# # \ \ = lim_(n rarr oo) 5/n sum_(i=1)^n \ ((5i)/n)^4# # \ \ = lim_(n rarr oo) 5/n sum_(i=1)^n \ (5/n)^4i^4# # \ \ = lim_(n rarr oo) 5/n * 625/n^4sum_(i=1)^n \ i^4# # \ \ = lim_(n rarr oo) 3125/n^5sum_(i=1)^n \ i^4#
Using the standard summation formula:
# sum_(r=1)^n r^4 = 1/30(6n^5+15n^4+10n^3-n) #
we have:
# I = lim_(n rarr oo) 3125/n^5 1/30 (6n^5+15n^4+10n^3-n)# # \ \ = lim_(n rarr oo) 625/6 (6+15/n+10/n^2-1/n^4)# # \ \ = 625/6 lim_(n rarr oo) (6+15/n+10/n^2-1/n^4)# # \ \ = 625/6 (6+0+0-0)# # \ \ = 625#
Using Calculus
If we use Calculus and our knowledge of integration to establish the answer, for comparison, we get:
# int_0^5 \ x^4 \ dx = [ x^5/5 ]_0^5 # # " " = 3125/5-0 # # " " = 625#
Sign up to view the whole answer
By signing up, you agree to our Terms of Service and Privacy Policy
Sign up with email
Answer 5
To find the area between the curve ( y = x^4 ) and the x-axis from ( x = 0 ) to ( x = 5 ), you can integrate the absolute value of the function over the given interval. The area is given by the integral:
[ \text{Area} = \int_{0}^{5} |x^4| , dx ]
You need to break this integral into two parts because ( x^4 ) changes sign at ( x = 0 ). The integral from ( x = 0 ) to the point where ( x^4 = 0 ) (which is ( x = 0 )) gives the area under the curve from ( x = 0 ) to the x-axis, and the integral from that point to ( x = 5 ) gives the area above the x-axis.
So, you can rewrite the integral as:
[ \text{Area} = \int_{0}^{5} x^4 , dx - \int_{0}^{0} x^4 , dx ]
Evaluate each integral separately:
[ \int_{0}^{5} x^4 , dx = \frac{1}{5}x^5 \bigg|_{0}^{5} = \frac{1}{5}(5)^5 - \frac{1}{5}(0)^5 = \frac{3125}{5} = 625 ]
[ \int_{0}^{0} x^4 , dx = 0 ]
So, the total area is ( 625 ) square units.
Sign up to view the whole answer
By signing up, you agree to our Terms of Service and Privacy Policy
Sign up with email
Answer from HIX Tutor
When evaluating a one-sided limit, you need to be careful when a quantity is approaching zero since its sign is different depending on which way it is approaching zero from. Let us look at some examples.
When evaluating a one-sided limit, you need to be careful when a quantity is approaching zero since its sign is different depending on which way it is approaching zero from. Let us look at some examples.
When evaluating a one-sided limit, you need to be careful when a quantity is approaching zero since its sign is different depending on which way it is approaching zero from. Let us look at some examples.
When evaluating a one-sided limit, you need to be careful when a quantity is approaching zero since its sign is different depending on which way it is approaching zero from. Let us look at some examples.
Not the question you need?
Drag image here or click to upload
Or press Ctrl + V to paste
Answer Background
HIX Tutor
Solve ANY homework problem with a smart AI
• 98% accuracy study help
• Covers math, physics, chemistry, biology, and more
• Step-by-step, in-depth guides
• Readily available 24/7
|
__label__pos
| 0.999587 |
Reply
Posts: 3
Registered: 08-21-2011
What does this button do?
I have the e4200 and yesterday, while trying to setup my new Mac computer and printer I totally screwed the network up. I pressed one button that must be where it all started. It is a small blue button on the back of the machine. It has two arrows going in a circle that marks it, I think. Somehow, I have gotten the router back to the default settings with a password to match. The named network I had is gone along with the guest access. What did I do? Help! Thanks.
Expert
Posts: 5,422
Registered: 11-11-2008
Re: What does this button do?
What does the manual say that button does?
Posts: 1,830
Registered: 04-22-2012
Re: What does this button do?
That blue button is the WPS(Wifi Protected Setup) button. If you press that button, it should help you in connecting other wireless devices to your router. That will depend though if other wireless devices has a wifi protected setup feature as well. One possible reason why you can't see the network is that after you pressed the button, the router may have change the wireless settings completely - from the network name to the password to something like a computer-generated password. But technically, pressing the wps button shouldn't cause this problem.
Expert
Posts: 1,329
Registered: 04-22-2012
Re: What does this button do?
Are you referring to this button (check the pic) That is the WPS button. Wi-fi protected setup.
E4200_back.JPG
Expert
Posts: 5,422
Registered: 11-11-2008
Re: What does this button do?
Oh, you mean from the manual... ok.
|
__label__pos
| 0.885887 |
All Products
Search
Document Center
Release an instance
Last Updated: Sep 19, 2017
One important feature of ECS is on-demand resource creation. You can create custom resources elastically on demand during peak service hours, and then release those resources after service computing is completed. This document describes how to easily release ECS instances and achieve elasticity.
This document covers the following APIs:
After an ECS instance is released, the physical resources used by the instance are recycled, including disks and snapshots. The data of the instance is completely lost and can never be recovered. If you want to retain the data, we recommend that you create snapshots of disks before releasing the ECS instance. The snapshots can be directly used to create a new ECS instance.
To release an ECS instance, you must stop it first. If any application is affected after the ECS instance is stopped, restart the instance.
Stop an ECS instance
Use the StopInstance interface to stop an ECS instance, regardless of the billing method of the instance. The stop command is as follows. When the ForceStop parameter is set to true, the ECS instance is stopped directly but data is not necessarily written to a disk, similar to power failure. Therefore, if you want to release an instance, set ForceStop to true.
1. def stop_instance(instance_id, force_stop=False):
2. '''
3. stop one ecs instance.
4. :param instance_id: instance id of the ecs instance, like 'i-***'.
5. :param force_stop: if force stop is true, it will force stop the server and not ensure the data
6. write to disk correctly.
7. :return:
8. '''
9. request = StopInstanceRequest()
10. request.set_InstanceId(instance_id)
11. request.set_ForceStop(force_stop)
12. logging.info("Stop %s command submit successfully.", instance_id)
13. _send_request(request)
Release an ECS instance
Use the DeleteInstance interface to release an ECS instance.
When the ECS instance is in the Stopped status, you can release it. The API has only two request parameters:
• InstanceId: Instance ID
• Force: If this parameter is set to “true”, the ECS instance is released forcibly even when it is not in the Stopped status. Use caution when setting this parameter. Release by mistake may affect your services.
1. def release_instance(instance_id, force=False):
2. '''
3. delete instance according instance id, only support after pay instance.
4. :param instance_id: instance id of the ecs instance, like 'i-***'.
5. :param force:
6. if force is false, you need to make the ecs instance stopped, you can
7. execute the delete action.
8. If force is true, you can delete the instance even the instance is running.
9. :return:
10. '''
11. request = DeleteInstanceRequest();
12. request.set_InstanceId(instance_id)
13. request.set_Force(force)
14. _send_request(request)
The following response is returned when an ECS instance is released successfully:
1. {"RequestId":"689E5813-D150-4664-AF6F-2A27BB4986A3"}
If you release an ECS instance when it is not in the Stopped status, an error occurs:
1. {"RequestId":"3C6DEAB4-7207-411F-9A31-6ADE54C268BE","HostId":"ecs-cn-hangzhou.aliyuncs.com","Code":"IncorrectInstanceStatus","Message":"The current status of the resource does not support this operation."}
Set the automatic release time for an ECS instance
You can set the automatic release time for an ECS instance to simplify instance management. When the set time is reached, Alibaba Cloud releases your ECS instance automatically. Use the ModifyInstanceAutoReleaseTime to set the automatic release time for an ECS instance.
Note:
The automatic release time follows the ISO8601 standard in UTC time. The format is yyyy-MM-ddTHH:mm:ssZ. If the seconds place is not 00, it is automatically set to start from the current minute.
The automatic release time must be at least half an hour later than the current time, and must not be more than 3 years since the current time.
1. def set_instance_auto_release_time(instance_id, time_to_release = None):
2. '''
3. setting instance auto delete time
4. :param instance_id: instance id of the ecs instance, like 'i-***'.
5. :param time_to_release: if the property is setting, such as '2017-01-30T00:00:00Z'
6. it means setting the instance to be release at that time.
7. if the property is None, it means cancel the auto delete time.
8. :return:
9. '''
10. request = ModifyInstanceAutoReleaseTimeRequest()
11. request.set_InstanceId(instance_id)
12. if time_to_release is not None:
13. request.set_AutoReleaseTime(time_to_release)
14. _send_request(request)
Run the command set_instance_auto_release_time('i-1111', '2017-01-30T00:00:00Z') to set the time. Then you can use the DescribeInstances to query the automatic release time.
1. def describe_instance_detail(instance_id):
2. '''
3. describe instance detail
4. :param instance_id: instance id of the ecs instance, like 'i-***'.
5. :return:
6. '''
7. request = DescribeInstancesRequest()
8. request.set_InstanceIds(json.dumps([instance_id]))
9. response = _send_request(request)
10. if response is not None:
11. instance_list = response.get('Instances').get('Instance')
12. if len(instance_list) > 0:
13. return instance_list[0]
14. def check_auto_release_time_ready(instance_id):
15. detail = describe_instance_detail(instance_id=instance_id)
16. if detail is not None:
17. release_time = detail.get('AutoReleaseTime')
18. return release_time
If you want to cancel the automatic release due to service changes, run the set_instance_auto_release_time('i-1111') command to set the automatic release time to null.
Complete example code
Note: Proceed with caution when releasing ECS instances.
1. # coding=utf-8
2. # if the python sdk is not install using 'sudo pip install aliyun-python-sdk-ecs'
3. # if the python sdk is install using 'sudo pip install --upgrade aliyun-python-sdk-ecs'
4. # make sure the sdk version is 2.1.2, you can use command 'pip show aliyun-python-sdk-ecs' to check
5. import json
6. import logging
7. from aliyunsdkcore import client
8. from aliyunsdkecs.request.v20140526.DeleteInstanceRequest import DeleteInstanceRequest
9. from aliyunsdkecs.request.v20140526.DescribeInstancesRequest import DescribeInstancesRequest
10. from aliyunsdkecs.request.v20140526.ModifyInstanceAutoReleaseTimeRequest import \
11. ModifyInstanceAutoReleaseTimeRequest
12. from aliyunsdkecs.request.v20140526.StopInstanceRequest import StopInstanceRequest
13. # configuration the log output formatter, if you want to save the output to file,
14. # append ",filename='ecs_invoke.log'" after datefmt.
15. logging.basicConfig(level=logging.INFO,
16. format='%(asctime)s %(filename)s[line:%(lineno)d] %(levelname)s %(message)s',
17. datefmt='%a, %d %b %Y %H:%M:%S')
18. clt = client.AcsClient('Your Access Key Id', 'Your Access Key Secrect', 'cn-beijing')
19. def stop_instance(instance_id, force_stop=False):
20. '''
21. stop one ecs instance.
22. :param instance_id: instance id of the ecs instance, like 'i-***'.
23. :param force_stop: if force stop is true, it will force stop the server and not ensure the data
24. write to disk correctly.
25. :return:
26. '''
27. request = StopInstanceRequest()
28. request.set_InstanceId(instance_id)
29. request.set_ForceStop(force_stop)
30. logging.info("Stop %s command submit successfully.", instance_id)
31. _send_request(request)
32. def describe_instance_detail(instance_id):
33. '''
34. describe instance detail
35. :param instance_id: instance id of the ecs instance, like 'i-***'.
36. :return:
37. '''
38. request = DescribeInstancesRequest()
39. request.set_InstanceIds(json.dumps([instance_id]))
40. response = _send_request(request)
41. if response is not None:
42. instance_list = response.get('Instances').get('Instance')
43. if len(instance_list) > 0:
44. return instance_list[0]
45. def check_auto_release_time_ready(instance_id):
46. detail = describe_instance_detail(instance_id=instance_id)
47. if detail is not None:
48. release_time = detail.get('AutoReleaseTime')
49. return release_time
50. def release_instance(instance_id, force=False):
51. '''
52. delete instance according instance id, only support after pay instance.
53. :param instance_id: instance id of the ecs instance, like 'i-***'.
54. :param force:
55. if force is false, you need to make the ecs instance stopped, you can
56. execute the delete action.
57. If force is true, you can delete the instance even the instance is running.
58. :return:
59. '''
60. request = DeleteInstanceRequest();
61. request.set_InstanceId(instance_id)
62. request.set_Force(force)
63. _send_request(request)
64. def set_instance_auto_release_time(instance_id, time_to_release = None):
65. '''
66. setting instance auto delete time
67. :param instance_id: instance id of the ecs instance, like 'i-***'.
68. :param time_to_release: if the property is setting, such as '2017-01-30T00:00:00Z'
69. it means setting the instance to be release at that time.
70. if the property is None, it means cancel the auto delete time.
71. :return:
72. '''
73. request = ModifyInstanceAutoReleaseTimeRequest()
74. request.set_InstanceId(instance_id)
75. if time_to_release is not None:
76. request.set_AutoReleaseTime(time_to_release)
77. _send_request(request)
78. release_time = check_auto_release_time_ready(instance_id)
79. logging.info("Check instance %s auto release time setting is %s. ", instance_id, release_time)
80. def _send_request(request):
81. '''
82. send open api request
83. :param request:
84. :return:
85. '''
86. request.set_accept_format('json')
87. try:
88. response_str = clt.do_action(request)
89. logging.info(response_str)
90. response_detail = json.loads(response_str)
91. return response_detail
92. except Exception as e:
93. logging.error(e)
94. if __name__ == '__main__':
95. logging.info("Release ecs instance by Aliyun OpenApi!")
96. set_instance_auto_release_time('i-1111', '2017-01-28T06:00:00Z')
97. # set_instance_auto_release_time('i-1111')
98. # stop_instance('i-1111')
99. # release_instance('i-1111')
100. # release_instance('i-1111', True)
If you want to learn other API operations in ECS, see ECS API operation.
|
__label__pos
| 0.991572 |
Same IP address with different port number
How to assign “A” record for same IP’s but with different port number?
I have two websites, and both are hosted in digital ocean server which means it takes the IP of the digital ocean server. In this case it is differentiated with the help of port number, but “A” record doesn’t accept port number. So, what is the right approach?
The short answer is that you can’t do this at the DNS level.
You could set up a reverse proxy on your server that listens on port 443 (and maybe 80) which forwards requests to your two services (neither of which would live on the standard/default ports).
This is a bit of an advanced configuration.
|
__label__pos
| 0.999537 |
Skip to content
Instantly share code, notes, and snippets.
Embed
What would you like to do?
Small F# script demonstrating extensible FizzBuzz implementation
let combine fs x y = Seq.fold (fun acc f -> acc || f x y) false fs
let matcher f (n, msg) i =
if f n i then
Some msg
else
None
module Option =
let combine op a b =
match a,b with
| Some x, Some y -> Some (op x y)
| None, x | x, None -> x
let eval predicates hits i =
let res =
hits
|> Seq.map (predicates |> combine |> matcher)
|> Seq.map (fun f -> f i)
|> Seq.reduce (Option.combine (+))
match res with
| Some x -> x
| None -> sprintf "%A" i
let isDivisibleBy a b = b % a = 0
let rec contains a b =
if b > 0 then
b % 10 = a || contains (b / 10) a
else
false
let test = eval [isDivisibleBy; contains] [(3, "Fizz"); (5, "Buzz"); (7, "Woof")]
[1..100]
|> Seq.map test
|> Seq.iter (printf "%s")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.
|
__label__pos
| 0.709008 |
SortableListDRGEP.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2 ========= |
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4 \\ / O peration |
5 \\ / A nd | www.openfoam.com
6 \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 Copyright (C) 2016 OpenFOAM Foundation
9 -------------------------------------------------------------------------------
10 License
11 This file is part of OpenFOAM.
12
13 OpenFOAM is free software: you can redistribute it and/or modify it
14 under the terms of the GNU General Public License as published by
15 the Free Software Foundation, either version 3 of the License, or
16 (at your option) any later version.
17
18 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 for more details.
22
23 You should have received a copy of the GNU General Public License
24 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25
26 \*---------------------------------------------------------------------------*/
27
28 #include "OSspecific.H"
29 #include <algorithm>
30
31 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
32
33 template <class Type>
35 :
36 List<Type>(values),
37 indices_(values.size())
38 {
39 sort();
40 }
41
42
43 template <class Type>
45 :
46 List<Type>(size),
47 indices_(size)
48 {}
49
50
51 template <class Type>
53 (
54 const label size,
55 const Type& val
56 )
57 :
58 List<Type>(size, val),
59 indices_(size)
60 {}
61
62
63 template <class Type>
65 (
66 const SortableListDRGEP<Type>& lst
67 )
68 :
69 List<Type>(lst),
70 indices_(lst.indices())
71 {}
72
73
74 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
75
76 template <class Type>
77 void Foam::SortableListDRGEP<Type>::setSize(const label newSize)
78 {
79 List<Type>::setSize(newSize);
80 indices_.setSize(newSize);
81 }
82
83
84 template <class Type>
86 {
87 forAll(indices_, i)
88 {
89 indices_[i] = i;
90 }
91
92 Foam::sort(indices_, less(*this));
93
94 List<Type> tmpValues(this->size());
95
96 forAll(indices_, i)
97 {
98 tmpValues[i] = this->operator[](indices_[i]);
99 }
100
101 List<Type>::transfer(tmpValues);
102 }
103
104
105 template <class Type>
107 {
108 forAll(indices_, i)
109 {
110 indices_[i] = i;
111 }
112
113 std::partial_sort
114 (
115 indices_.begin(),
116 indices_.begin()+M,
117 indices_.end(),
118 less(*this)
119 );
120 }
121
122
123 template <class Type>
125 {
126 forAll(indices_, i)
127 {
128 indices_[i] = i;
129 }
130
131 Foam::stableSort(indices_, less(*this));
132
133 List<Type> tmpValues(this->size());
134
135 forAll(indices_, i)
136 {
137 tmpValues[i] = this->operator[](indices_[i]);
138 }
139
140 List<Type>::transfer(tmpValues);
141 }
142
143
144 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
145
146 template <class Type>
147 void
149 {
151 indices_ = rhs.indices();
152 }
153
154
155 // ************************************************************************* //
OSspecific.H
Functions used by OpenFOAM that are specific to POSIX compliant operating systems and need to be repl...
Foam::SortableListDRGEP::operator=
void operator=(const SortableListDRGEP< Type > &)
Definition: SortableListDRGEP.C:148
Foam::HashTableOps::values
List< T > values(const HashTable< T, Key, Hash > &tbl, const bool doSort=false)
List of values from HashTable, optionally sorted.
Definition: HashOps.H:149
Foam::less
static bool less(const vector &x, const vector &y)
To compare normals.
Definition: meshRefinementRefine.C:57
Foam::SortableListDRGEP::indices
const labelList & indices() const
Return the list of sorted indices. Updated every sort.
Definition: SortableListDRGEP.H:104
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:296
Foam::stableSort
void stableSort(UList< T > &a)
Definition: UList.C:268
Foam::SortableListDRGEP::partialSort
void partialSort(int M)
Partial sort the list (if changed after construction time)
Definition: SortableListDRGEP.C:106
Foam::SortableListDRGEP
A list that is sorted upon construction or when explicitly requested with the sort() method.
Definition: SortableListDRGEP.H:52
Foam::List::transfer
void transfer(List< T > &list)
Definition: List.C:459
Foam::sort
void sort(UList< T > &a)
Definition: UList.C:254
Foam::List::operator=
void operator=(const UList< T > &a)
Assignment to UList operator. Takes linear time.
Definition: List.C:501
Foam::List< Type >
Foam::SortableListDRGEP::stableSort
void stableSort()
Sort the list (if changed after construction time)
Definition: SortableListDRGEP.C:124
M
#define M(I)
Foam::SortableListDRGEP::sort
void sort()
Sort the list (if changed after construction time)
Definition: SortableListDRGEP.C:85
Foam::SortableListDRGEP::setSize
void setSize(const label)
Size the list. If grow can cause undefined indices (until next sort)
Definition: SortableListDRGEP.C:77
Foam::List::setSize
void setSize(const label newSize)
Alias for resize(const label)
Definition: ListI.H:146
Foam::SortableListDRGEP::SortableListDRGEP
SortableListDRGEP(const List< Type > &)
Construct from List, sorting the elements. Starts with indices set.
Definition: SortableListDRGEP.C:34
|
__label__pos
| 0.747889 |
CODES AND CYPHERS
NOTES
VULNERABILITIES AND SECURITY CONSIDERATIONS
1. A possible method of reading the plaintext would be by gaining access to the computers used by either end and locating the key files or plaintexts from that machine, so it is important to delete all plaintext and key files after sending.
2. The re-use of a key text can raise the possibilities that a plaintext can be recovered
3. Another vulnerability is if the uses selects a key text that can be guessed by a person familiar with their literary preferences.
INSTRUCTIONS For ENCRYPTION
1. After installing PYTHON3, and the IDE (Development Environment tool).
2. Create a folder on two USB sticks or similar memory devices, and copy the cypher program on to each.
3. Start IDLE program
4. IDLE PROGRAM select window
From the IDLE top-bar menu: FILE: OPEN: then traverse to the folder containing the program and select OPEN:
5. Select the RUN button:
6. Select ENCRYPT:
7. Select "Select Text File" Button
and traverse to the plaintext file and select OPEN
8. Repeat the above, selecting the key file
9. A file of name format: Enc_(Day)_(Month)_(Hour)_(Minutes)_(Seconds)_(Year).txt is created in the XXXX folder
The format is a series of numbers separated by spaces. DO not edit or change the file content, but it may be copied and pasted into another file or email body.
81 102 112 149 84 113 133 107 115 60 72 106 104 101 114 130 153 72 126 108 99 116 156 131 126 143 129 117 100 154 125 106 115 114 120 139 60 141 113 118 149 83 121 114 118 115 94 130 135 72 100 106 119 118 134 28 101 103 134 145 117 117 116 154 7 116 138 148 131 104 116 140 117 109 60 105 112 117…….
INSTRUCTIONS For DECRYPTION
…. notes produced so far. --- work in progress \
|
__label__pos
| 0.60461 |
System is processing data
Please download to view
...
Ejercicios resueltos de el algebra de baldor
by diegomendoz
on
Report
Category:
Education
Download: 19
Comment: 0
3,726,439
views
Comentarios
Descripción
Download Ejercicios resueltos de el algebra de baldor
Transcript
• 1. EJERCICIO 11. Una deuda se expresa en sentido EJERCICIO 3negativo. Luego inicalmente el estadoeconómico de Pedro es - 60 bs.Al recibir 320 bs. Aumenta su capital1. + 32 m ; − 16 mtantos bs. como ha recibido; entonces2. + 10 m ; − 4 mla operaciòn queda expresada comose indica3. 50 − 85 = − 35 m − 60 + 320 = + 260 bs.4. − 6 ⋅11= − 66m2. 1.170 − 1. 515 = − 345 sucres 5. -8 × 6 =-48 m3. 200 + 56 − 189 = + $ 67 9 × 6 =+ 54 m4. − 665 − 1.178 + 2 . 280 = + 437 soles5. 20 − 15 + 40 − 75 = − $ 306. 400 ⋅ 2 = + 800 m → corredor− 400 ⋅ 3 = − 1. 200 m → yo6. − 67 + 72 − 16 + 2 = − $ 9 7. Los 40 pies de longitud del poste7. 200 − 78 − 81− 93 + 41− 59 = − 70 colones se reparten asi: 15 pies que sobresalen8. − 45 − 66 − 79 + 200 − 10 = 0 - se asumen en sentido positivo- . 25 pies que se encuentran enterrados. - se asumen en sentido negativo - . Al introducir 3 pies màs, se adicionanEJERCICIO 2 a los que estan bajo el suelo y se deben descontar de los que estan por encima.1. 12 − 15 = − 3!Aritmèticamente significa:2. − 3 + 8 − 6 = − 1! 40 = 15 + 25− 25 − 3 = − 28 pies3. 15 − ( − 3) = 15 + 3 = 18! + 15 − 3 = + 12 pies ( )4. − − 8 + 5 = 8 + 5 = 13!5. − 4 + 7 + 2 − 11= − 6!8. 55 − 52 = + 3 m 9. − 32 + 15 = − 17m6. − 8 + 4 ⋅1 = − 8 + 4 = − 4! → 7 am 10. 35 − 47 = − 12 m − 8 + 4 ⋅ 2 = − 8 + 8 = 0! → 8 am − 8 + 4 ⋅ 5 = − 8 + 20 = + 12! → 11am 11. − 39 + 56 = + 17m 12. 90 − 58 − 36 = − 4 m7. − 1− 2 ⋅ 2 = − 1− 4 = − 5! → 10 am 13. 72 − 30 ⋅1= 72 − 30 = + 42 m − 1− 2 ⋅ 3 = − 1− 6 = − 7! → 11am 72 − 30 ⋅ 2 = 72 − 60 = + 12 m − 1− 2 ⋅ 3 + 3 ⋅1= − 1− 6 + 3 = − 4! → 12 am 72 − 30 ⋅ 3 = 72 − 90 = − 18 m − 1− 2 ⋅ 3 + 3 ⋅ 3 = − 1− 6 + 9 = + 2! → 2 pm 72 − 30 ⋅ 4 = 72 − 120 = − 48 m8. − 56 + 7 = − 49! 14. − 120 − (− 60) ⋅ 1 = − 120 + 60 = − 60 Km9. − 71 + 5 = − 66! long − 120 − (− 60) ⋅ 2 = − 120 + 120 = 0 − 15 + (− 5) = − 20! lat. − 120 − (− 60) ⋅ 3 = − 120 + 180 = + 60 Km − 120 − (− 60) ⋅ 4 = − 120 + 240 = + 120 Km10. 18 + 3 =+ 21! long65 -4 =+ 61! lat.11. -75 +135 =+ 60 años
• 2. EJERCICIO 7. 27. 11a + 8a + 9a + 11a = 39a1. x + 2x = 3x 28. mx + 1 + 3mx + 1 + 4mx + 1 + 6mx + 1 = 14mx + 12. 8a + 9a = 17a 29. − x2 y − 8x2 y − 9x2 y − 20x2 y = − 38x 2 y3. 11b + 9b = 20b 30. − 3am − 5am − 6am − 9am = − 23am4. − b − 5b = − 6b1 114 + 2 +1 + 8155. − 8m − m = − 9m 31.a+ a+ a+a =a=a2 48886. − 9m − 7m = − 16m 2 11 18 + 10 + 2 + 121 32. ax + ax +ax +ax =ax =ax7. 4a x + 5a x = 9a x5 2 1020 20 208. 6a x + 1 + 8a x + 1 = 14a x + 1 33. 0,5m + 0,6m + 0,7m + 0,8m = 2,6m9. − mx + 1 − 5mx + 1 = − 6mx + 111 1 34. − ab − ab − ab − ab 7 142810. −3a x − 2 − a x − 2 = − 4a x − 2 − 4 − 2 − 1− 2835 5 = ab = −ab = − ab1 1 1+ 1228 28 411. a+ a=a = a =a2 222 2 3 111 33 16ab + ab 735. − x y − x 3y − x3y −x y 3 69 1212. ab +ab = =ab5101010−2 4 − 6 − 4 − 3 337 3 = x y=−x y 36361 1 2 +1 3113. xy + xy =xy = xy = xy3 66 6236. ab 2 + ab 2 + 7ab 2 + 9ab 2 + 21ab 2 = 39ab 21 4 − 1− 4537. − m − m − 8m − 7m − 3m = − 20m14. − xy − xy == − xy = − xy5 555 38. − x a + 1 − 8x a + 1 − 4x a + 1 − 5x a + 1 − x a + 1 = − 19x a + 15 21 − 20 − 3 2 23 215. − a b − a 2b = a b =−ab1 1 11 1682424 39. a+ a+ a+ a+ a 2 3 45 67−8−71530 + 20 + 15 + 12 + 10872916. − a − 8 a = 8 a = − 8 a=a=a=a60 602017. 8a + 9a + 6a = 23a 111 1118. 15x + 20x + x = 36x40. − ab − ab − ab −ab − ab 3 62 12919. − 7m − 8m − 9m = − 24m −12 − 6 − 18 − 3 − 443 =ab = −ab36 3620. − a 2b − a 2b − 3a 2b = − 5a 2b21. a x + 3 a x + 8a x = 12a x22. − 5a x + 1 − 3a x + 1 − 5a x + 1 = − 13a x + 1 EJERCICIO 8 1 26+3+41323. a + a + a = a=a 1. 8a − 6a = 2a 2 36 62 1 − 6 − 4 −111 2. 6a − 8a = − 2a24. − x − x− x=x=− x3 6 6 63. 9ab − 15ab = − 6ab1 3 2 + 3 + 1015 3 4. 15ab − 9ab = 6ab25. ax +ax + ax =ax =ax = ax51010 10 2 5. 2a − 2a = 035−9 − 10 − 12 231 2 6. − 7b + 7b = 026. − a x − a x − a x = a x=− 2 2 2 a x46 12 12 7. − 14xy + 32xy = 18xy
• 3. 8. − 25x 2 y + 32x 2 y = 7x 2 y5 m + 1 7 m + 1 10 − 7 m +1 3 m + 1 1 m + 1 35. a −a =a =a = a 6 12 12 1249. 40x 3 y − 51x 3 y = − 11x 3y1 2 12 − 1 2 11 2 36. 4a − a = a = a 210. −m2n + 6m2n = 5m2n33 311. − 15xy + 40xy = 25xy3− 20 + 317 37. − 5mn +mn =mn = −mn12. 55a 3b 2 − 81a 3b 2 = − 26a 3b 24 4 413. − x 2 y + x 2 y = 038. 8a x + 2b x + 3 − 25a x + 2b x + 3 = − 17a x + 2b x + 314. −9ab 2 + 9ab2 = 07 m n m n −7+8 m n 1 m n 39. − a b +a b = a b = a b 88815. 7x2 y − 7x2 y = 0 40. 0,85mxy − 0,5mxy = 0,35mxy16. − 101mn + 118mn = 17mn17. 502ab − 405ab = 97ab18. − 1024 x + 1018x = − 6x EJERCICIO 919. −15ab + 15ab = 01 3 2−31 1. 9a − 3a + 5a = 11a20. a− a= a=− a2 44 4 2. − 8x + 9x − x = 03 1 3−2 13. 12mn − 23mn − 5mn = − 16mn21. a− a= a= a4 2444. − x + 19x − 18x = 05 2 5 2 10 − 5 25 25. 19m − 10m + 6m = 15m22. a b−a b=a b=a b61212126. −11ab − 15ab + 26ab = 0 4 2 9 2−8+ 9 21 2 7. − 5a X + 9a X − 35a X = − 31a X23. − x y +x y=x y=x y 714 14 14 8. − 24a X + 2 − 15a X + 2 + 39a X + 2 = 03 5 3 − 10 724. am − am =am = − am 2 1 2 + 1− 3 08 4 88 y+ y−y=y= y=0 9. 3 33 33−5+3 225. − am +am =am = − am3 11− 12 + 5 − 10175 5 5 10. − m+ m− m = m =−m 5 42 20205 7 20 − 21 126. mn − mn = mn = −mn3 213+2− 8 2 36 8 24 24 a b + a 2b − a 2b = a b = − a 2b 11.8488 3 2 − 11+ 3 2 827. − a b + a b=a b = − a 2b 2 12. − a + 8a + 9a − 15a = a 11 11 11 13. 7ab − 11ab + 20ab − 31ab = − 15ab28. 3,4a 4b3 − 5,6a 4b 3 = − 2,2a 4b 3 14. 25x 2 − 50x 2 + 11x 2 + 14x 2 = 029. − 12yz + 3,4yz = 2,2yz , 15. − xy − 8xy − 19xy + 40xy = 12xy30. 4a x − 2a x = 2a x 16. 7ab + 21ab − ab − 80ab = − 53ab31. − 8a x + 1 + 8a x + 1 = 0 17. − 25xy 2 + 11xy 2 + 60xy 2 − 82xy 2 = − 36xy 232. 25ma − 1 − 32ma − 1 = − 7ma − 1 18. −72ax + 87ax − 101ax + 243ax = 157ax33. − x a + 1 + x a + 1 = 019. − 82bx − 71bx − 53bx + 206bx = 01 m − 2 1 m − 2 − 1+ 2 m − 2 1 m − 2 20. 105a 3 − 464a 3 + 58a 3 + 301a 3 = 034. − a+ a =a = a4 24 4
• 4. 1 111x− x+ x− x=30 − 20 + 15 − 12x= 13xEJERCICIO 1021.2 34560601 1114 − 4 + 2 −1 122. y− y+ y−y=y=y 1. 7a + 6a − 9b − 4b3 36 12 12 127a + 6a = 13a − 9b − 4b = − 13b3 21 2 1 2 = 13a − 13b23. 5 a b − 6 a b + 3 a b − a b 218 − 5 + 10 − 30 2 7 22. a + b − c − b − c + 2c − a= a b=−a b a−a =0b −b =0− c − c + 2c = 0 30 30 =05 2 1 23 224. − 6 ab − 6 ab + ab − 8 ab23. 5x − 11y − 9 + 20x − 1− y− 20 − 4 + 24 − 9 29 3 5x + 20x = 25x − 11y − y = − 12y − 9 − 1 = − 10=ab = −ab 2 = − ab2= 25x − 12y − 10 24 24 825. − a + 8a − 11a + 15a − 75a = − 64a4. − 6m + 8n + 5 − m − n − 6m − 1126. − 7c + 21c + 14c − 30c + 82c = 80c − 6m − m − 6m = − 13m 8n − n = 7n5 − 11= − 6 = − 13m + 7n − 627. − mn + 14mn − 31mn − mn + 20mn = mn28. a 2 y − 7a 2 y − 93a 2 y + 51a 2 y + 48a 2 y = 05. − a + b + 2b − 2c + 3a + 2c − 3b − a + 3a = 2a b + 2b − 3b = 0 − 2c + 2c = 029. − a + a − a + a − 3a + 6a = 3a = 2a1 2 71x+ x− x+ x−x30.2 3 626. − 81x + 19y − 30z + 6y + 80x + x − 25y3+4−7+3−631− 81x + 80x + x = 0 19y + 6y − 25y = 0− 30z= x=− x= − x662= − 30z3 1 5 7. 15a 2 − 6ab − 8a 2 + 20 − 5ab − 31+ a 2 − ab31. − 2x + 4 x + 4 x + x − 6 x 15a 2 − 8a 2 + a 2 = 8a 2 − 48 + 18 + 6 + 24 − 20 20 5=x=−x= − x− 6ab − 5ab − ab = − 12ab 20 − 31= − 11 2424 6 = 8a − 12ab − 11 232. 7a x − 30 a x − 41a x − 9a x + 73a x = 08. − 3a + 4b − 6a + 81b − 114b + 31a − a − b33. − a x + 1 + 7a x + 1 − 11a x + 1 − 20a x + 1 + 26a x + 1 = a x + 1 −3a − 6a + 31a − a = 21a34. a + 6a − 20a + 150a − 80a + 31a = 88a4b + 81b − 114b − b = − 30b35. − 9b − 11b − 17b − 81b − b + 110b = − 9b = 21a − 30b36. − a 2b + 15 a 2b + a 2 b − 85 a 2b − 131a 2b + 39 a 2b = − 162 a 2b9. − 71a b − 84a b + 50a b + 84a b − 45a b + 18a b 34 2 34 23 337. 84m2 x − 501m2 x − 604m2 x − 715m2 x + 231m2 x + 165m2 x − 71a 3b + 50a 3b − 45a 3b + 18a 3b = − 48a 3b= − 1340m2 x − 84a 4b 2 + 84a 4b2 = 05 3 2 2 3 2 1 3 2 5 3 2= − 48a 3b38. a b + a b − a b − a b + 4a 3b 2634820 + 16 − 6 − 15 + 96 3 2 111 3 2 10. − a + b − c + 8 + 2a + 2b − 19 − 2c − 3a − 3 − 3b + 3c=ab = ab 2424 −a + 2a − 3a = − 2a b + 2b − 3b = 0=37 3 2 a b = 4 5 a 3b 2 − c − 2c + 3c = 0 8 − 19 − 3 = − 1488 = − 2a − 1439. 40a − 81a + 130a + 41a − 83a − 91a + 16a = − 28a40. − 21ab + 52ab − 60ab + 84ab − 31ab − ab − 23ab = 0
• 5. 11. m + 71mn − 14m − 65mn + m − m − 115m + 6m 2 23223m + 6m = 7m33 3 m − 14m − m − 115m2 = − 129m2 22 271 − 65mn = 6mnmn= 7m3 − 129m2 + 6mn12. x y − x y + x y − 8x y − x y − 10 + x y − 7x y − 9 + 21x y − y + 5043 2242 3 2 3 2 43x 4 y − 8x 4 y + 21x 4 y = 14x 4 y− x 3 y 2 + x 3 y 2 − 7x 3 y 2 = − 7x 3y 2 x 2y − x2y = 0− y3− 10 − 9 + 50 = 31 = 14x y − 7x y − y + 31 4 3 2 313. 5a x + 1 − 3b x + 2 − 8c x + 3 − 5a x + 1 − 50 + 4b x + 2 − 65 − b x + 2 + 90 + c x + 3 + 7c x + 3− 8c x + 3 + c x + 3 + 7c x + 3 = 0− 3b x + 2 + 4b x + 2 − b x + 2 = 05a x + 1 − 5a x + 1 = 0− 50 − 65 + 90 = − 25= − 2514. am + 2 − xm + 3 − 5 + 8 − 3am + 2 + 5xm + 3 − 6 + am + 2 − 5xm + 3− x m + 3 + 5 x m + 3 − 5x m + 3 = − x m + 3am + 2 − 3am + 2 + am + 2 = − am + 2−5+8−6= −3m+3 m+2=−x−a −315. 0,3a + 0,4b + 0,5c − 0,6a − 0,7b − 0,9c + 3a − 3b − 3c0,3a − 0,6a + 3a = 2,7a 0,4b − 0,7b − 3b = − 3,3b0,5c − 0,9c − 3c = − 3,4c= 2,7a − 3,3b − 3,4c1 1 31 3 116. a + b + 2a − 3b − a − b + −2 3 46 4 2132+8−37 1 12 − 18 − 1 17 3 1 3−2 1a + 2a − a =a= a b − 3b − b =b=−b− = =24 4 4 3 66 6 4 24 47171= a−b+4 643 2 1117. m − 2mn + m2 − mn + 2mn − 2m251033 21 6 + 1− 20 2 13 1− 6 − 1+ 6 1m + m2 − 2m2 =m = − m2 − 2mn −mn + 2mn =mn = − mn5 1010 10 333 13 2 1= − m − mn 10 318. − 3 a 2 + 1 ab − 5 b 2 + 2 1 a 2 − 3 ab + 1 b 2 − 1 b 2 − 2ab 34 26 46 33 2 7 2 − 9 + 28 2 19 2 1 3 2−3−8 9− a + a =a = aab − ab − 2ab = ab = − ab4 31212 2 4 4 45 2 1 2 1 2 − 5 + 1− 2 2 6 2− b + b − b =b =− b =−b 26636 619 2 9=a − ab − b 2124
• 6. 3 2 2119. 0,4x y + 31+ xy − 0,6y 3 − x 2 y − 0,2xy 2 + y 3 − 62 8 5422−2 2 3 23 − 16 2 14 2 ,,0,4x 2 y − x 2 y = x y=0 xy − 0,2xy 2 =xy = xy = 0,175xy 255 88 8 1 − 2,4 + 1 3, 14 3− 0,6y 3 + y 3 =y =− y = − 0,35y 3 31− 6 = 254 4 4= 0,175xy 2 − 0,35y 3 + 25 37 m − 2 3 m−1 1 m− 2 1 a m−1 b − + a − b− 0,2a m − 1 + b m − 220. 2550 5 25 5 3 m − 1 3 m −1 3 + 15 − 5 m − 1 13 m − 17 m − 2 1 m − 2 1 m − 2 − 7 − 2 + 10 m − 2 1 m − 2 a + a − 0,2a m − 1 =a =a−b −b+ b =b =b255 25 2550 25 5 505013 m − 1 1 m − 2=a + b2550EJERCICIO 11Para resolver los problemas del 1 al 18 las literales toman los siguientes valores:a = 1 b = 2 c = 3 m = 1/2 n = 1/3 p = 1/41. 3ab = 3 ⋅1⋅ 2 = 64a4 ⋅1 4 22. 5a 2b3 c = 5 ⋅12 ⋅ 23 ⋅ 3 = 5 ⋅ 8 ⋅ 3 = 12012.= ==3bc 3 ⋅ 2 ⋅ 3 18 9 2 1 1 4 23. b mn = 2 ⋅ ⋅ = =2 2 2 3 6 3 11 5⋅ 2 2 ⋅ 20 ⋅5b m 2 2 24 = 5 = 6013.= = 2 3 1 111 1 614. 24m n p = 24 ⋅= 6⋅ ⋅ == 1 1 1 1 2 3np 2 34 27 4 108 18⋅ 3 41212 3 2 4 2 3 2 4 2 1 2 1 8 13 3 3 3 3 ⋅ 8 245. a b m = ⋅ 1 ⋅ 2 ⋅ = ⋅ 4⋅ = = ⋅2 33 2 3 8 24 314. 4 b6 =4= 4 = 4 = =1 2 2 2 2 2 ⋅ 9 18 67 3 2 7 2 1 1 189 1 1 189 63c⋅36.c p m = ⋅ 33 ⋅ ⋅ =⋅ ⋅ = =333 3 1212 4 2 12 16 2 384 1281 2⋅ 2 3 1 11 1 1 1 17. m n p = ⋅= ⋅ ⋅ =2m 2 = 1 = 1=3b c a 2 34 4 27 4 432 15.=n2 12 1 1 5 b −1 c − 2 5 2 −1 1 3− 2 5 1 5 39 38. a ⋅ m = ⋅1 ⋅ = ⋅ = 66 26 2 12 1 1 249.2bc 2 = 2 ⋅ 2 ⋅ 32 = 4 ⋅ 9 = 36 = 624mn24 ⋅ ⋅ 416. =2 3= 6=2 ⋅ n2 p2 2 1 1 21 1 11 3 2⋅ 2⋅⋅2⋅10. 4m ⋅ 12bc = 4 ⋅ ⋅ 12 ⋅ 2 ⋅ 32 = 2 ⋅ 3 216 = 2 ⋅ 6 = 12322 3 4 9 161444 4 1 118 4== = 2411. mn ⋅ 8a b = ⋅ ⋅ 8 ⋅14 ⋅ 23 = ⋅ 64 = = 4 31 1 2 366 32⋅ 12 6
• 7. 3 ⋅ 3 64 ⋅ 2 3 ⋅ 3617. 3 ⋅ 64b c = 33 6= 3 ⋅ 3 64 ⋅ 8 ⋅ 729 = 3 ⋅ 3 373.248 = 3 ⋅ 72 = 216 2m1 2⋅ 233 1 3 4 33 318. ⋅ apb 2⋅ 1⋅ ⋅ 2 2 ⋅⋅ 15 = 5 4= 5 4 = 5 =5 = 5 = 6 = 2 3 3250 3 ⋅ 3 125 3 ⋅ 515 75 25 ⋅ 125bm 3 ⋅ 3 125 ⋅ 2 ⋅ 1 3 ⋅ 3 222 2 2 2 22EJERCICIO 12Para resolver los problemas del 1 al 18 las literales toman los siguientes valores:a = 3 b = 4 c = 1/3 d = 1/2 m = 6 n = 1/41. a 2 − 2ab + b 2 = 32 − 2 ⋅ 3 ⋅ 4 + 42 = 9 − 24 + 16 = 11 1 1 4 + 12 + 9 25 22 11 1 12. c + 2cd + d = + 2 ⋅ ⋅ + = + + ==2 2 33 2 29 3 4 3636a b 3 43. + =+ = 9 + 8 = 17c d 11 3 21 c m62 2 − 72 + 6644.− +2= 3 − + 2 = − 24 + 2 ==− d n1 133 32 4a 2 b 2 m2 32 42 62 9 16 365. − + = − += −+ = 3 − 8 + 6 =132 6 3 2 6 3 2 6313 1 1 1 1 1− 10 + 546.c − b + 2d = ⋅ − ⋅ 4 + 2 ⋅ = − 2 + 1= =−525 3 2 2 5 55 1 13⋅4⋅ ab ac bd 3 ⋅ 43 − 2 = 12 + 1 − 2 = 48 + 2 − 1 = 144 + 6 − 1 = 149 = 49 2 +−=+ 37. n d m11 61 1 63 33 4 24 2 114 + 1+ 12 178. b + n + 6m = 4 ++ 6⋅6 = 2 + + 6 == =8 2 1 4222 111 1 1 1 11 2 − 16 + 1139. c 3a − d 16b + n 8d = ⋅ 3 ⋅ 3 − ⋅ 16 ⋅ 4 + ⋅ 8 ⋅ = ⋅ 3 − ⋅16 + ⋅ 2 = 1− 8 + = =−=−6 2 2 1 2 324 2 3 2 42 22 ma63 21610.=4 = = 216 ⋅ 16 = 3.456 11 b d 2 16
• 8. 22 1 11 13 4 11. 3 c 2 + 4n = 3 + 4 = 3 + 4 = 1 + 1 = 2 + 1 = 3 = 1 24m 46 4 6 12 24 24 24 8 22 4d 2 16n 2 1 1 2 8 1 112.+− 1= 2 ⋅ + 8 ⋅ − 1 = + − 1 = + − 1= 1 − 1 = 02 2 2 4 4 162 2 a + b b + m 3 + 4 4 + 6 7 10− = − = − = 21− 20 = 113.c d 1 1 1 1 3 2 3 2 b−a m−b4−3 6−41 2++ 5a =++ 5 ⋅ 3 = + + 15 = 4 + 4 + 15 = 2314. n d1 1 1 1 4 2 4 2 1 1 12 ⋅− 3 16 ⋅ − 312c − a 16n − a 13 4 1 4−3 4−31 13 − 4 + 48 4715.− + =− + = −+2= − +2= == 1 232bm d 2⋅46 18 6 8 62424 24 2 3a 6m 3⋅ 3 6⋅69 363 616. 4b +−= 4⋅4 +− = 16 + −= 4 + − = 4 + 1− 1= 4 36363 6 3 6 1 114 + 2⋅3⋅ + 8⋅17. b + 2d 3c + 8d 2 32 2 + 1 1+ 2 3 3 6 − 3 3 − = −=−= − = =2 4 2424 2 4 44 29 13⋅ 2 + 3⋅2 ⋅ a b 3⋅ 2 + d 2 2 22⋅ 3 ⋅4 2 1 2 ⋅ 14424 2118.+ − a⋅ n =+− 3⋅ = +− 3⋅3 4 34 4 342 3 9 2 ⋅ 12 3⋅ 2 3 24 2 39 3 64 + 9 − 12 61 5 =+− = + − = 8+ − = = =783 4 23 4 2 8 288EJERCICIO 13Para los problemas 1 al 24 las literales toman los siguientes valores:a = 1 b = 2 c = 3 d = 4 m = 1/2 n = 2/3 p = 1/4 x = 01. (a + b)⋅ c − d = (1 + 2)⋅ 3 − 4 = 3 ⋅ 3 − 4 = 9 − 4 = 5 ()( ) ()(2. a + b b − a = 1 + 2 2 − 1 = 3 ⋅ 1 = 3) 1 2 4 − 1 9 − 2 7+8 ( )(2 )3. b − m c − n + 4a = 2 − 3 − + 4 ⋅ 1 = 2 3 2 + 4= ⋅ + 4= + 4= 2 3 2 32 2 3 7 7 = 15 1 2 =724.(2m + 3n)(4 p + b ) = 2 ⋅ 2 + 3⋅ 2 4 ⋅ 4 + 2 = (1+ 2)(1+ 4) = 3⋅ 5 = 15 21 3 1 21 ()( 2 )( 42 2 ) 3 15. 4m + 8 p a + b 6n − d = 4 ⋅ + 8 1 + 2 6 ⋅ − 4 = 2 + 2 ⋅ 3⋅ 0 = 0 2 2()2 ( )
• 9. 2 − 1 1 ( )()( )( ) (6. c − b d − c b − a m − p = 3 − 2 4 − 3 2 − 1 − = 1⋅ 1⋅ 1 )( )( ) 2 1 1 4 = 4 4 1 2 3+ 4 7 168 − 7 1612 (2 )2(7. b c + d − a m + n + 2 x = 2 3 + 4 − 1 2 )()+ + 2⋅ 0 = 4⋅ 7 − 2 3 6 = 28 − =6 6 = 6= 26 5 6 () 1 ()8. 2mx + 6 b + c − 4d = 2 ⋅ ⋅ 0 + 6 2 + 3 − 4 ⋅ 4 = 6 4 + 9 − 4 ⋅ 16 = 6 ⋅ 13 − 64 = 78 − 64 = 142 22 2 2 22 ( ) 1 1 8⋅16 ⋅ 8m 16 p + a=2+ 4 ⋅1 = 4 + 4 = 4 + 2 = 2 + 2 = 2 + 6 = 8 = 2 29. 9n b 3 9⋅ 22 18 2 63 3 3 3 3 (10. x + m a + d − c = 0 + b c a ) 2 (1 + 4 − 3 ) = 2 (1+ 64 − 3) = 2 ⋅ 62 = 31 1 2 3 1 11 1 111.(4 m + p a 2 + b2 ÷ = 2) 4 + 4 1 + 2 ÷ 22 2 + 1 1 + 4= 4÷3 5 3 27= 4⋅ ÷ = = =52 2 ac1 32 4 9 4 9 5 5 59 ()(12. 2m + 3n + 4 p 8 p + 6n − 4m 9n + 20 p)() 1 1 11 2 1 = 2 ⋅ + 3⋅ + 4 ⋅ 8 ⋅ + 6 ⋅ − 4 ⋅ 9 ⋅ + 20 ⋅ = ( 1 + 2 + 1)(2 + 4 − 2)(6 + 5) = 4 ⋅ 4 ⋅ 11 = 176 2 2 2 3 4 43 2 3 4 (13. c m + n − d m + p + b n + p 2 2 2 )()()1 2 1 1 2 1 73 11 21 44 126 − 144 + 44 26 = 32 + − 4 2 + + 2 2 + = 9 ⋅ − 16 ⋅ + 4 ⋅ = − 12 += == 2 12 = 2 1 22 3 2 4 3 4 64 12 212 1212 6 c2 + d 2 2 32 + 4 2 2 1 9 + 16 2 1 25 2 11 5m= ⋅ = ÷÷ 2 1 ÷ 2 ⋅ 2 = 1 ÷ 2 ⋅ 2 = 5⋅ 2 = 2 = 2 2114. a d 1 4 15. (4 p + 2b)(18n − 24 p) + 2 (8m + 2)(40 p + a ) 1 1 1 1 = 4 ⋅ + 2 ⋅ 2 18 ⋅ − 24 ⋅ + 2 8 ⋅ + 2 40 ⋅ + 1 = (1 + 4)(12 − 6) + 2 (4 + 2) (11) = 5⋅ 6 + 2 ⋅ 66 = 30 + 132 = 1622 434 2 4 225+ 2 5+ d 24 1 2+ 4 1 6a+5 + 2 1+ b⋅ m = 2⋅ 22 ⋅ 4 = 2 ⋅ 5 + 8 = 3 ⋅ 5 + 8 = 3 ⋅ 13 = 3 ⋅ 208 = 624 = 31216. =d −b p2 4 − 2 1 2 2 1 2 1 2 1 2 1 2 2 4 161616 16 22 90 − 2 88 2 () 2( )17. a + b ⋅ c + 8b − m ⋅ n = 1 + 2 ⋅ 3 + 8 ⋅ 2 − ⋅ = 3⋅ 25 − ⋅ = 3⋅ 5 − = 15 − = 22 12 31 22 326 6 6= = 14 4 = 14 26 63 2 a+c 1+ 3 6⋅ 6n 1 44 ÷ (c + d )⋅ p = ÷ (3 + 4)⋅31 2 4 + += + ÷ 7⋅ = =18. 2 b 22 4 2 2 2 7 7 2
• 10. ( )( )19. 3 c − b ⋅ 32m − 2 d − a ⋅ 16 p − 2 n = 3 (3 − 2)⋅ 32 ⋅ − 2 (4 − 1)⋅ 16 ⋅ − = 3⋅ 16 − 6 ⋅ 4 − = 3⋅ 4 − 6 ⋅ 2 − 3 = 12 − 12 − 3 = − 31 1 2 62 4 2 2 3 6abc 3mn cdnp20. +− 2 ⋅ 8b 2(b − a ) abc 1 2 2 1 3⋅ ⋅ 6 ⋅ 1⋅ 2 ⋅ 33⋅ 4 ⋅ ⋅ =+ 2 3 − 3 4 = 36 + 1 − 2 = 6 + 1 − 1 = 18 + 12 − 8 = 22 = 11 2 ⋅ 8⋅ 2 2(2 − 1) 1⋅ 2 ⋅ 3 2 ⋅ 16 2 6 8 2 32424 12 a 2 + b2 12 + 2 25 + 216 2212 + 3 (a + b)(2a + 3b) = 2 + 3 (1 + 2)(2 ⋅ 1 + 3⋅ 2) = + 3⋅ 3⋅ 8 = + 72 =5 521.== 73 2 b −a22 − 123 3 33 3 2 1 1 1 1 1 1 22. b + + + + + 2 a b b c n m 2 1 1 1 1 1 1 22 3 5 3 5 7 21 49 70 35 = 2 + + + + + = 4 + ⋅ + + 2 = 4 + + = +2 = = = 17 21 1 2 2 3 2 1 2 6 2 4 2 4 4 4 2 3 2 (2m + 3n)(4 p + 2c) − 4m 2n24 189 − 4 185 2 2 1 2 1 1 2 = 2 ⋅ + 3⋅ 4 ⋅ + 2 ⋅ 3 − 4 = (1 + 2)(1 + 6 ) − 4 ⋅ ⋅ = 3⋅ 7 − = 21 − =23. 1 44 == 20 9 5 2 3 4 2 3 4 999 99 c322 b2 − 22 − 3 − n =3 − 3 = 3 − 3 = 3 − 4 = 6 − 4 = 54 − 28 = 2624. 2ab − m b − m 111 3 7 9 7 9 63632 ⋅1⋅ 2 − 2− 4−222 2 2EJERCICIO 141. a + b + m ( 10. $ x + a − m )18. x 2 m22. m2 + b3 + x 4 ( 11. m − a − b − c Km)() (19. $ 3a + 6b ; $ ax + bm) 12. $ (n − 300)3. a + 1 ; a + 220. (a + b)( x + y )4. x − 1 ; x − 2 13. (365− x) días21. $ (8 x + 48)5. y + 2 ; y + 4 ; y + 622. bs. (a − 8)(x + 4) 14. $ 8a ; $15a ; $ ma (6. $ a + x + m)c 15. 2a + 3b +757. m − n 223.sucres x (8. bs. x − 6)16. a ⋅ b m2a (9. x − m Km) 17. 23n m2 24. $m
• 11. 3.00025. n − 1 colonesa +b 29. $ m − 2x26. a − 3 solesx 30. x + 2 x + hab.2m m27.14 a 2a 31. 1000 − a + + sucres3 4 . x +1 km28. h aEJERCICIO 15 3 21. m, n → m + n20. − 4x 2 y ,x y 8( )2. m , − n → m + − n = m − n 3 − 4x 2 y + x 2 y =− 32 + 3 2x y=−29 2x y3. − 3a , 4b → − 3a + 4b 8 884. 5b , 6a → − 6a + 5b 33 21. mn , − mn( )5. 7 , − 6 → 7 + − 6 = 7 − 6 = 1 84 333−6 36. − 6 , 9 → − 6 + 9 = 3 mn − mn = mn = − mn 84 887. − 2x , 3y → − 2x + 3y 22. a , b , c → a + b + c8. 5mn , − m → 5mn + (− m) = 5mn − m 23. a , − b , c → a − b + c9. 5a , 7a → 5a + 7a = 12a 24. a , − b , 2c → a − b + 2c ( )10. − 8 x , − 5x → − 8 x + − 5x = − 8 x − 5x = − 13x 25. 3m , − 2n , 4p → 3m − 2n + 4p11. − 11m , 8m → − 11m + 8m = − 3m 26. a 2 , − 7ab , − 5b2 → a 2 − 7ab − 5b212. 9ab , − 15ab → 9ab − 15ab = − 6ab 27. x 2 , − 3xy , − 4y 2 → x 2 − 3xy − 4y 213. − xy , − 9xy → − 9xy − xy = − 10xy 28. x3 , − x2 y , 6 → x3 − x 2y + 6 ( )14. mn , − 11mn → mn + − 11mn = mn − 11 mn = − 10mn 29. 2a , − b , 3a → 2a + 3a − b = 5a − b 1 21 215. a , − b → a− b 30. − m , − 8n , 4n → − m − 8n + 4n = − m − 4n 2 32 3 31. −7a , 8a , − b → − 7a + 8a − b = a − b333 316. b, c→ b+ c 1 2 3545 432. x, y, − x 2 3 4121 23 4−617. b, b→ b+ b= b=b1 3 2 x− x+ y= 2 12 x+ y=− x+ y333 33 2 4 383 431 111218. − xy , − xy → − xy − xy = − xy = − xy322 2222 33. − 5 m , − m , − 3 mn 3 2 32 −3−528 219. −abc , − abc − m − m − mn =m − mn = − m − mn 5 5 53535 3 3 2 5− abc − abc = − abc = − abc34. − 7a 2 , 5ab , 3b 2 , − a2 5 5 5 − 7a 2 − a 2 + 5ab + 3b 2 = − 8a 2 + 5ab + 3b 2
• 12. 35. − 7mn2 + 17mn2 − 5m − 4m = 10mn2 − 9m EJERCICIO 1636. x − 7x − 8x y + 4x y + 5 = − 6x − 4x y + 5 3 3 2 2 3 21. 3a + 2b − c37. 5x2 − x 2 + 9xy − 6xy + 7y 2 = 4x2 + 3xy + 7y210.ab + bc + cd 2a + 3b + c− 8ab − 3bc − 3cd38. − 8a 2b − a 2b + 5ab 2 − 11ab 2 − 7b 3 5a + 5b5ab + 2bc + 2cd= − 9a b − 6ab − 7b 2 2 3− 2ab2.7a − 4b + 5c − 7a + 4b − 6c39. m − 8m n + 7m n + 7mn − n32 22 311. ax − ay − az= m − m n + 7mn − n32 23−c− 5 ax − 7ay − 6az3.m+n−p 4 ax + 9ay + 8az1 12 140. a − a + b+ b−6 −m−n+ p2 43 5 ay + az2 −110 + 3 1130=a+b−6= a +b−64 15 41512. 5x − 7y + 84.9x − 3y + 5 − 4x − y + 641. a − a − 3b + 4b − 8c + 8c = b− x − y +4− 3x + 8y + 9 − 5x + 4 y − 9− 2x+ 2342. m3 + 5m3 − 5m3 − 4m2n − 4m2n − 7mn23x= m3 − 8m2n − 7mn213. − am + 6mn − 4s5.a+ b − c− am − 5mn + 6s43. 9x − x − 11y − 6y + 4z − 6z = 8x − 17y − 2z 2a + 2b − 2c3am − 5mn − 2s − 3a − b + 3c am − 4mn44. 6a + 9a − 5ab − 7b − 8b − 1122222b= 15a − 5ab − 15b − 11 2 214. 2a + 3b6.p+ q+ r 6b − 4c45. − x y + x y − 5xy + 7 xy − 4y − 8 2 2 2 2 3 3 4 − 2p − 6q + 3r −a+ 8c= 2xy 3 − 4y 4 − 8p + 5q − 8ra + 9b + 4c 11− 4r46. 3a − a + b − b − 4 + 6 2 215. 6m − 3n6 −11− 2 5 1− 4n + 5p=a+b+2= a− b+22 22 27. − 7x − 4y + 6z −m − 5p 10x − 20y − 8z1 2 3 2 2 15 5 5m − 7nx + x + xy − xy + y 2 − y 2− 5x + 24y + 2z47.243 36 6 − 2x2 + 3 2 2 −15 2 1 16. 2a + 3b= x +xy = x + xy4 3 43 + 5c − 48. − 2m + 3n − 6 8a +648. 5ax − 5ax − 6a x + 1 + a x + 1 + 5a x + 1 + 8a x + 2 = 8a x + 23m − 8n + 8+ 7c − 93 2 2 2 11 − 5m + n − 1010a + 3b + 12c − 749. x + x − xy − xy + y 2 + 5y 24 3 33 − 4m − 4n − 83+ 4 2 31+ 15 2 7 216 2 17. 2x − 3y=x − xy + y = x − xy +y 43 343 + 5z + 99. − 5a − 2b − 3c 6x −43 2 111550. a b − a 2b + a 2b + ab 2 + ab 2 − ab 27a − 3b + 5c 3y−544 2263 − 1+ 4 2 3+3−5 3 21− 8a + 5b − 3c 8x + 5z= a b+ ab = a b + ab 2246 26− 6a −c
• 13. 18. 8a + 3b − c 21. 5a x − 3am − 7an24.a+ b − c +d5a − b + c− 8a + 5a − 9a xm na− b + c −d−a −b − c − 2a + 3b − 2c + d− 11a x + 5am + 16an7a − b + 4c − 3a − 3b + 4c − d− 14a x + 7am19a + 3c− 3a+ 2ca +122. 6m − 7m a+2 − 5ma + 325. 5ab − 3bc + 4cd19. 7x + 2y −4 a +1 a+2 a+3+ 2bc + 2cd − 3de+ 9y − 6z + 54m − 7m−m− 2ab + 4bc+ 3de− y + 3z − 6− 5ma + 1 + 3ma + 2 + 12ma + 3− ab − 3bc − 6cd8 x − 3y −5 5ma + 1 − 11ma + 2 + 6ma + 32ab15x + 7y − 3z − 1026. a − bb−c20. − m − n − p23. 8x + y + z + uc+dm + 2n −5−c− 3x − 4y − 2z + 3ua− 6m+ 3p + 4 c−d4x + 5y + 3z − 4u 5m + 2n −8 −a+d− 9x − y + z + 2u a−d − m + 3n + 2p − 9 y + 3z + 2u2aEJERCICIO 177. m2 + n212. a3− 4a + 5 + 4n2 − 3mna 3 − 2a 2 +61. x + 4 x 2 x 2 − 5x− 5m − 5n 22 + a − 7a + 42 2x 2 − x− 4m2− 3mn 2a − a 2 − 11a + 15 32. a + ab28. 3x + x 3 13. − x2 + x − 6− 2ab + b 2− 4x 2 + 5 x − 7x 23 +5 a − ab + b22− x + 4x − 6 32−x 3+ 8x − 5 3x −1− 8x + 9x − 623. x 3+ 2x − x2+4 9. x 2 − 3xy + y 214. a3− b3 x − x + 2x + 43 2− x + 3xy − 2y2 2 + 5a b − 4ab2 2 x 2 + 3xy − y 2a 3− 7ab2 − b34. a 4− 3a 2 x + 3xy − 2y2 22a 3 + 5a 2b − 11ab 2 − 2b 3 + a3+ 4a a 4 + a 3 − 3a 2 + 4a10. a 2 − 3ab + b 2 15. x 3 + xy 2 + y 3+ a − 5ab − b 22 x − 5x y3 2− y35. − x 2 + 3x− 2a + 8ab − b 222x 3− 4xy 2 − 5y 3 x3+6−b24x 3 − 5x 2 y − 3xy 2 − 5y 3 x 3 − x 2 + 3x + 611. − 7x 2 + 5x − 6 − 7m2n + 4n36. x 2 − 4 x16.4 x + 8x − 9 2+m3+ 6mn − n32 − 7x + 6 −x2 − 7x + 14− m + 7m n3 2 + 5n3 3x 2 −5 − 4 x 2 + 6x − 1 + 6mn2 + 8n3 4x 2 − 11x + 1
• 14. 24. − 8a 2m + 6am2 − m317. x4− x2 + x+ a 3 − 5am2 + m3 + x 3 − 4x 2 +5 − 4a + 4a m − 3am232+ 7x 2 − 4x + 6+ 7a 2m − 4am2−6x 4 + x 3 + 2x 2 − 3x + 11 − 3a + 3a m − 6am322−618. + a + a4+6625. x5− x 3y 2− xy 4 +a 5− 3a3+8+ 2x y4+ 3x y2 3 − y5+ a 3 − a 2 − 14+ 3x y3 2− 4xy − y 54+ a + a + a − 2a − a 65432 x5 + 5xy 4 + 2y 52x 5 + 2 x 4 y + 2 x 3 y 2 + 3x 2 y 319. x5+ x −9 + 3x 4− 7x 2+6 26.a 5 + a6 + a2− 3x 3− 4x + 5 + a 4 + a3 + 6x 5 + 3x 4 − 3x 3 − 7x 2 − 3x + 2 + 3a 2− 8 + 5a−a5− 4a 2 + 6 − 5a20. a + a+a+a +a +4 36 4 3+ a2 + 527.a4 − b4 + 4a + 7 a 2− a 3b + a 2b 2 − ab 3− 8 a2 − 6− 3a + 5a 3b − 4a 2b 24a 3 + 5a −1− 4a 3b + 3a 2b 2 − 3b 4− 2a 4− ab 3 − 4b 421. x4− x 2y2 − 5x 3 y + 6xy 3 28.m3 − n3 + 6m2n− 4 xy 3 + y 4+ n3 − 4m2n + 5mn2− 4x y2 2 −6m − n33+ 6mn2x 4 − 5x 3 y − 5x 2 y 2 + 2xy 3 + y 4 − 6 − 2m + n − 2m n3 3 2 11mn222. + x + xy 229. ax− 3a x − 2− x 2 + 4 xy − 7y 2 x −1 + 5a + 6a x − 3− x 2 + 6xy + 5y 2+ 7a x − 3 + a x − 4− 6x 2 − 4xy + y 2+ ax −1 − 13a x − 3− 7 x 2 + 7 xy − y 2x −1x−2a + 6a x− 3a + ax − 423.a 3 − 8ax 2 + x 330. − a x + a x + 1 + ax + 2 − 6ax − x + 5a x232− 3a x+3−ax −1 +a x−23a 3− x 3 − 5a 2 x−a x+ 4ax+3− 5a x + 2a + 14ax − x 323+a x −1 −a x−2+ ax + 25a 3 − 2x 3 − 2a x + a x + 1 + a x + 3− 3a x + 2x+3 x+2 x +1⇒a− 3a+a − 2a x
• 15. 5 2 2 23EJERCICIO 18 6.x − y+ xy 6 34 1 211. x +xy 1− x2 + 1 2 y−1xy 236 821 1+ xy + y21− x2 + 1 2 y+5xy2 43 46 1 2 2+3 1 1 51 5 − 1− 2 2 − 16 + 3 + 6 2 9 − 6 + 10 x + xy + y 2 = x 2 + xy + y 2x +y + xy 2 6 4 2 64 6 241227 2 13 1137 2 1= x2 − y +xy ⇒ x 2 + xy −y2. a + 2 ab2 6 24 12 312 24 11 21 2 7. a 3− ab +b3− ab +b2 42 3 25 2 11− ab −2b 3 + a b− ab − b286 45 1 33 31 2a −b− a b 2 − 1− 15−2 2 3 2452 a +2ab + b = a2 +b4 10104 + 1 3 − 4 − 3 2 5 − 10 − 3 3 5 − 3 2 a + ab + b + a b 4 8 5 65 78251 78 2= a 3 − ab 2 − b 3 + a 2b ⇒ a 3 + a 2b − ab 2 − b 33. x 2+xy 4 85643 85 3 1 8. x4− x2 + 5− xy + y2 62 3 3−3 +x − x 52 3 8− xy + y2 63 3 45 33− x+ x −x 4 − 1− 53+2 2564 x2 + xy + y 63 5−3 4 24+5 3 −3−6x − x + 2+ x + x 251556 8 = x 2 − xy + y 2 = x 2 − xy + y 2 6333299 2 39= x 4 − x2 + 2 + x3 − x ⇒ x4 + x 3 − x 2 − x + 2 568 5 28 3 21 2 2 3 12 34. x −y9. m − mn2 +n 42 3 452 1 2 13 31 2−xy + y+mn2 −n+ m n5 6 8561 2 11 2 m3− n3− m n+ xy +y 21032 + 3 3 −2 + 1 2 2 − 3 − 5 3 1− 3 2 3 2 − 4 +1− 3 + 1+ 2 2 3 2 3m +mn +n +m n x +xy + y = x −xy3 856 4 106410 5 16 251 16= m3 − mn2 − n3 − m2n ⇒ m3 − m2n − mn2 − n 338 5 633 852 2 1 1 22 45.a+ab− b10. x 4+ 2x 2 y 2 + y35275 2 1 1 2 5 4 3 2 2 1 4 1 3a− ab + b − x + x y −y− xy610 6 6 814 6 1 2 2 1 4 5 31 211 2 −x y + y − x y −a+ab− b4 7 6 12 2036 − 5 4 16 + 3 − 2 2 2 4 − 1+ 2 4 1 3 5 3 8 + 10 − 1 2 4 − 2 + 1− 3 + 1− 2 2 x +x y + y − xy − x y a +ab + b6 814 661220 61 17 2 2 5 4 1 3 5 3= x4 +x y +y − xy − x y 17 2 3 417 2 326814 6 6 =a +ab − b2 =a +ab − b2 12 20612 20 31 4 5 3 17 2 2 1 3 5 4⇒ x − x y+ x y − xy + y66 8 6 14
• 16. 2 3 411. x −+ 13. a − +6 5 x x a4 a2 3 5 3 5 3 31 1 3 2+a − a − a− 3x 5 − x + x 58 210 8 3 45 21 3 1 2 2 4 −a −a+6 +x−x − x786 4 3 31 33 − a −6 − x + x−4 8 125−7 −3 4 8−5 2 3 5 3 3 −4−3 − 8 + 2 − 1 3 8 − 1+ 63−2 2 2 4 a6 + a +a + a − a + a− 2x 5 +x + x+x − x −47 8 58 8 12 108310 4 3 2 3 5 3 3 7 = a6 −a + a + a − a − a 78 58 8 7 3 1312= − 2x 5 − x +x + x2 − x4 − 4 3 5 10 4 3 3 3 2 712 1083⇒ a6 + a −a − a + a − a57 8 8 8 27 3 1 2 13⇒ − 2x 5 − x 4 −x + x +x −4 3 12 8 102 3 5 21 3 14. x5 −y512. a+ax − x 1 3 2 3 4 1 59 63 + x y − xy −y10463 7 21 3 − a2x− ax − x− 1 5 y+3 45x y − x2y37 89 9562 3 21 5 2 11 2 − x y −y+ 2x 4 y− a3 + a2x− ax53 3 24 1− 4 3 2 3 4 − 18 − 3 − 2 − 6 5 3 + 10 45 x5 +x y − xy +y + x y − x2y3 2−6 3 −6+7 220 − 21− 6 2 − 3 − 1 3104 1856a + a x+ax + x 3 3 2 3 4 29 5 13 4 59 1424 9 = x5 −x y − xy −y +x y − x2 y 3104 185641 27 4= − a3 + a x−ax 2 − x 3⇒ x5 +13 4x y−3 3 2 5 2 3 3 4 29 5x y − x y − xy −y9 142495 106418EJERCICIO 19Para los problemas 1 al 14 las literales toman los siguientes valores:a = 2 b = 3 c = 10 x = 5 y = 4 m = 2/3 n = 1/5 3. x4 − y41. 4x − 5y2x 4− 5x 2 y 2 − 8 − 3x + 6y − 8− 4x4 + 7x 3y + 10xy 3 − x+ y − x 4 − y 4 − 5x 2 y 2 − 8 + 7x 3 y + 10xy 3 2y − 8⇒ − x 4 + 7x 3 y − 5x 2 y 2 + 10xy 3 − y 4 − 8 ⇒ 2⋅4 − 8 = 8 − 8 = 0= − 54 + 7 ⋅ 5 3 ⋅ 4 − 5 ⋅ 52 ⋅ 4 2 + 10 ⋅ 5 ⋅ 4 3 − 4 4 − 8= − 625 + 28 ⋅125 − 5 ⋅ 25 ⋅16 + 50 ⋅ 64 − 256 − 8= − 625 + 3.500 − 2.000 + 3.200 − 256 − 8 = 3.8112.x 2 − 5x + 8 − x 2 + 10x − 30 4.3m − 5n + 6 − 6x 2 + 5x − 50 − 6m − 20n + 8 − 6x 2 + 10x − 7212m − 20n − 12 ⇒ − 6 ⋅ 5 2 + 10 ⋅ 5 − 72 = − 6 ⋅ 25 + 50 − 72 9m − 45n + 2 = − 150 + 50 − 72 = − 172 2118 45⇒ 9 ⋅ − 45 ⋅ + 2 =− + 2 = 6 − 9 + 2 = −1 35 3 5
• 17. 5.nx + cn − ab 8nx − 2cn − ab 10.x 3 y − xy 3 + 5nx − ab − 5 5x 3 y− 6 + x 4 − x 2y2 10nx − cn − 3ab − 5− 6xy + 23 + x2 y21 1 ⇒ 10 ⋅ ⋅ 5 − 10 ⋅ − 3 ⋅ 2 ⋅ 3 − 5+ 3xy 3 + 1 − y45 56x 3y − 4xy 3 + 2 + x 4− y4 50 10 = − − 6 ⋅3 − 5 ⇒ x + 6x y − 4xy − y + 24 33 45 5 = 10 − 2 − 18 − 5 = − 15 = 5 4 + 6 ⋅ 53 ⋅ 4 − 4 ⋅ 5 ⋅ 43 − 44 + 2= 625 + 24 ⋅125 − 20 ⋅ 64 − 256 + 26. a3 + b3= 625 + 3.000 − 1280 − 256 + 2 = 2.091 . − 3a b + 8ab − b 3 22 − 5a 3− 6ab 2 +8 3 2a 2 2 b +11. + 3a b2− 2b3 43 1 1 − 4a3 + 2ab − 2b3 + 82− ab + b 2 3 9 ⇒ − 4 ⋅2 + 2⋅2⋅3 − 2⋅3 + 83 23 1 1 + ab − b 2 = − 4 ⋅ 8 + 4 ⋅ 9 − 2 ⋅ 27 + 86 3 = − 32 + 36 − 54 + 8 = − 423 2 − 2 +16 + 1− 3 2a −ab +b4 697. 27m 3 + 125n 3 3 1 4= a 2 − ab + b 2 − 9m n + 25mn 22 4 6 9 − 14mn 2−83 14⇒ ⋅ 22 − ⋅ 2 ⋅ 3 + ⋅ 32 + 10m n + 11mn 2 2 4 6931 4 27m3 + m2 n + 22mn 2 + 125n 3 − 8= ⋅ 4 − ⋅ 6 + ⋅ 9 = 3 − 1+ 4 = 6 322 346 9 2 2 1 2 1 1 ⇒ 27 ⋅ + ⋅ + 22 ⋅ ⋅ + 125 ⋅ − 8 3 3 5 3 5 5 9 2 25 218 4 1 44 11m +n− = 27 ⋅+ ⋅ + ⋅ + 125 ⋅ −8 12. 17 34427 9 5 3 25 125 7 25 21 4 444 44m +n+ − 15mn =8++ + 1− 8=++134 17245 75 45 75 7 2 1 20 + 132 + 225 377 −m − − 30mn == = 1 152225 34 4225 225 + 3 a −1+ y b − 2 + mx − 418 + 7 − 7 2 25 + 10 2 − 1 + 2 − 1 + 128. xm +n +− 45mna −1 b−2x −434344 2x− 2y− 2m 18 2 35 2 12 b−2=m +n +− 45mn + 3y− 2m x − 4 34 3449 235 2 3x a −1 + 2 y b − 2 − 3mx − 4⇒ 17m − 45mn + 34n +35−4 2 22 9 2 2 1 35 1 ⇒ 3⋅ 52 −1 + 2 ⋅ 4 3 − 2 − 3 = 15 + 8 − 2 = 21 = − 45⋅ ⋅ +17 3 +33 5 34 5 39 4 90 35 1 =⋅ −+⋅ +3b −1 x −317 9 15 34 259.n− m+8 4 354 7= − 6+ + 3=+ −3 − 5nb −1 − 3m x − 3 + 10 17850 17 17040 + 7 − 5104634nb −1 + 5m x − 3 − 18= =− = − 2 123 170 170170 mx − 3 5−3 2 224 ⇒ = = 3 39
• 18. 1 2313. b m −cn− 214. 0,2a 3 + 0,4ab2 − 0,5a 2b253 2 1+ 0,6ab2 − 0,3a 2b − 0,8b 3b m− cn +6410 − 0,4a 3 − 0,8a 2b +61 21− b m+ cn +40,2a 3 + 15a 2b + 0,9b3,4 251− b 2m +2cn + 3ab 2 − 0,1a 2b + 0,1b 3 + 685⇒ − 0,1a b + ab + 0,1b3 + 6224 + 6 − 2 −1 2 − 30 − 5 + 2 + 100− 10 + 30 + 20 + 3b m+cn += − 0,1⋅ 22 ⋅ 3 + 2 ⋅ 32 + 0,1 ⋅ 33 + 68 50 5 7 26743 7 2 2 67 1 43= − 0,3 ⋅ 4 + 2 ⋅ 9 + 0,1⋅ 27 + 6⇒ b m+ cn += ⋅3 ⋅ +⋅10 ⋅ + 850 5 8 3 50 55= − 12 + 18 + 2,7 + 6 ,7 ⋅ 9 ⋅ 2 67 43 126 670 43 21 67 43= ++ = ++=+ + = 25,52450 524 250 5 4 25 5525 + 268 + 8601. 653= == 16 100 53 100100EJERCICIO 2021. − 8xa + 2 − 11= − 8xa + 2 − 111. − 8 − 5 = − 1322. 6a n − (− 5a n ) = 6a n + 5a n = 11a n2. − 7 − 4 = − 113. 8 − 11 = − 3 23.− 45a x −1 − (− 60a ) = − 45a + 60a = 15ax −1x −1 x −1x −14. − 8 − (− 11) = − 8 + 11 = 324. 54bn −1 − (− 86b ) = 54b + 86b = 140bn −1 n −1n −1 n −1( )5. − 1 − − 9 = − 1 + 9 = 86. 2a − 3b = 2a − 3b25. − 35ma− (− 60m ) = − 35m + 60m = 25m aaaa7. 3b − 2 = 3b − 2 11 10 + 1 11 126. 5 − − = 5 + = 2= =528. 4x − 6b = 4x − 6b 2229. − 5a − 6b = − 5a − 6b2 3−8−91727. −− ==− ( )10. − 8 x − − 3 = − 8 x + 3 3 4 12 1211. −9a − 5b2 = − 9a 2 − 5b 2 21 2 2 2 1 2 2 2 3 2 228. x −− x = x + x = x = x3 3 3 3 3( )12. − 7 xy − − 5 yz = − 7 xy + 5 yz4 3 5 3 24 + 25 3 49 313. 3a − 4a = − a 29. x y − − x y =x y=x y5 6 303014. 11 2 − 25 m2 = − 14m2m1 2 3 2 − 1+ 6 2 5 2− 6 x 2 y − (− x 2 y) = − 6x 2 y + x 2 y = − 5x 2 y 30. − ab − − ab = ab = ab15. 8 4 8 816. 11a 3m2 − (− 7a 3m2 ) = 11a 3m2 + 7a 3m2 = 18a 3m231. − 2 − 3 = − 5( )32. 7 − − 1 = 7 + 1 = 817. − 8ab 2 − (− 8ab 2 ) = − 8ab 2 + 8ab 2 = 033. − 8 − (− 5) = − 8 + 5 = − 318. 31x 2 y − (− 46 x 2 y) = 31x 2 y + 46 x 2 y = 77 x 2 y34. 5 − (− 4 ) = 5 + 4 = 919. − 84a 2b − (− 84a 2b) = − 84a 2b + 84a 2b = 0 35. − 7 − (− 7) = − 7 + 7 = 020. 3a x + 1 − 5b x + 2 = 3a x + 1 − 5b x + 2 36. 2a − (− 5) = 2a + 5
• 19. 37. −3x − b = − 3x − bEJERCICIO 2138. − 2n − 5m = − 2n − 5m1.a +b2. 2x − 3y (39. 3b − − 6a = 6a + 3b) −a +bx − 2y40. 8b − (− 5a ) = 5a + 8b 332b3x − 5y41. − 7a − (− 9 ) = − 7a + 93. 8a + b 4. x − 3x2 (42. 25ab − − 25 = 25 ab + 25 ) 3a −4 5x − 6 11a + b − 4 x 2 + 2x − 6 ( )43. 3a − − a = 3a + a = 4a44. − 4b − (− 3b) = − 4b + 3b = − b 5. a − a b326. x−y+z54 x 3 − (− 11x 3 ) = 54 x 3 + 11x 3 = 65x 3− 7a 2b − 9ab 2−x+y−z45. a 3 − 8a 2b − 9ab 2046. 78a 2b − 14a 2b = 64a 2b47. − 54a 2 y − (− 43a 2 y ) = − 54a 2 y + 43a 2 y = − 11a 2 y48. − ab − 9ab = − 10ab 7. x + y − z8. x 2 + y 2 − 3xy x+ y − z− 3x 2 + y 2 + 4xy49. − 31x y − (− 31x y) = − 31x y + 31x y = 02 22 2 2 x + 2 y − 2z− 2x 2 + 2y 2 + xy50. − 3a − a = − 4a x xx ⇒ − 2x 2 + xy + 2y 251. 311a x +1 − (− 7a x +1 ) = 311a x +1 + 7a x +1 = 318a x +19. x3 − x2 + 610. y2+ 6y 3−852. 105m − 9m = 96m x xx − 5x − 6 + 4 x 23y − 2y 24 − 6y53. − 31ax −1 − 18a x −1= − 49a x −1 x − 6x 2 3 + 4x4 y 2 − 2y 4 + 6y 3 − 6 y − 8⇒ − 2y 4 + 6 y 3 + 4 y 2 − 6y − 854. − 236ma −(− 19m ) = − 236maa + 19ma = − 217ma55. − 85a x + 2 − 54a x + 2 = − 139a x + 211. a 3 − 6ab 2 + 9a + 8a − 15a 2b − 556. − (− 6a ) = + 6a 1 1 4 4a 3 − 6ab 2 + 17a − 15a 2b − 5 2 − 2 + 15 13⇒ a 3 − 15a 2b − 6ab 2 + 17a − 557. − − ( − 5) = = 33312. x 4 + 9xy 3 − 11y 4 7 3 3 358. − m − m− 20y 4 + 8x 3y + 6x 2 y 2108− 56 − 30 3 86 343 3x 4 + 9xy 3 − 31y 4 + 8x 3 y + 6x 2 y 2=m =−m =−m 80 8040⇒ x 4 + 8x 3y + 6x 2 y 2 + 9xy 3 − 31y 4 5 2 2 11 2 2 13. a + b + c − d ab + 2ac − 3cd − 5de59.a b −− ab 14. 6 12 − 8ab + 4ac + 5cd − 5dea + b−c+d 10 + 11 2 2 21 2 2 7 2 2 = ab =ab = ab2a + 2b − 7 ab + 6ac + 2cd − 10de 12 12 415.x 3 + 6x 2 − 9x − 191 3 260. − a b − 45a 3b 2 − 6x 3 + 11x 2 − 21x + 439− 1− 405 3 2 − 406 3 2 − 5 x 3 + 17 x 2 − 30x + 24= ab = a b = − 45 9 a 3b2199
• 20. 16. y − 9y + 6y − 31 53 2 − 31y 3 + 8y 2 + 11y 4 + 19yy 5 − 40y 3 + 14 y 2 + 11y 4 + 19y − 31 ⇒ y 5 + 11y 4 − 40y 3 + 14 y 2 + 19y − 3117.5m3 − 9n3 + 6m2n − 8mn2− 5m3 + 21m2n − 14mn2 + 18 − 9n3 + 27m2n − 22mn2 + 18 ⇒ 27m2n − 22mn2 − 9n3 + 1818.4 x 3 y − 19xy 3 + y 4 − 6x 2 y 225x 3 y + 51xy 3 − 32 x 2 y 2 + x 429x 3 y + 32 xy 3 + y 4 − 38x 2 y 2 + x 4 ⇒ x 4 + 29 x 3 y − 38x 2 y 2 + 32 xy 3 + y 419. m + m n − 9m n + 19 6 4 2 2 4 + 30m2n4 + 61+ 13m3n3 − 16mn5m6 + m4n2 + 21 2n4 + 80 + 13m3n3 − 16mn5 ⇒ m6 + m4n2 + 13m3n3 + 21m2n4 − 16mn5 + 80m20.− a 5b + 6 a 3b 3− 18 ab 5 + 428a 6+ 11a b 4 2 + 11a b2 4 − 9b 68a 6 − a 5 b + 11a 4 b 2 + 6a 3b 3 + 11a 2b 4 − 18 ab 5 − 9b 6 + 4221. 1 − x + x − x + 3x − 6x 2 4 3524 + 30x 2 − 8x 4 − 15x+ x625 + 29 x 2 − 7 x 4 − x 3 − 12x − 6x 5 + x 6 ⇒ x 6 − 6 x 5 − 7 x 4 − x 3 + 29 x 2 − 12 x + 2522. − 6x 2 y 3 + 8 x 5 − 23x 4 y + 80x 3 y 2 − 18 + 51x 4 y + 21x 3 y 2 − 80 + y 5 − 9xy 4− 6x 2 y 3 + 8 x 5 + 28x 4 y + 101x 3 y 2 − 98 + y 5 − 9xy 4 ⇒ 8x 5 + 28x 4 y + 101x 3 y 2 − 6 x 2 y 3 − 9xy 4 + y 5 − 9823. m6− 8m4n2 + 21m2n4 − 6mn5+ 8 23m n5− 14m n 3 3+ 24mn5 − 8n6 + 14m6 + 23m5n − 8m4n2 − 14m3n3 + 21 2n4 + 18mn5 − 8n6 + 22m24. x − 8x + 16x − 23x − 15 75 2 − 51x+ 18 + 8 x 6 − 25 x 4 + 30x 3x 7 − 59x + 16x 5 − 23x 2 + 3 + 8x 6 − 25x 4 + 30x 3 ⇒ x 7 + 8x 6 + 16x 5 − 25 x 4 + 30x 3 − 23x 2 − 59 x + 325. 9a 6 − 15a 4b 2 + 31a 2b 4 − b 6+ 14 + 15a b4 2− 3 b − 25a b − 53 a b + 9 ab6 53 359a 6+ 31a b − 4b 6 − 25a 5b − 53 a 3b 3 + 9 ab 5 + 14 ⇒ 9a 6 − 25a 5b − 53 a 3b 3 + 31a 2b 4 + 9 ab 5 − 4b 6 + 142 4 ax + ax +1 − ax + 2− 5a x + 6a x + 1 + a x + 226.− 4a x + 7a x + 1
• 21. a −127. m − m a + 3ma − 24ma − 5ma − 2 − 3ma + 1 − 8ma − 35ma − ma − 1 − 2ma − 2 − 3ma + 1 − 8ma − 3 ⇒ − 3ma + 1 + 5ma − ma − 1 − 2ma − 2 − 8ma − 3m+428. a − 7am + 2 − 8a m + 6am − 1+ 14a m + 2+ 8a m − 1 + 5am + 3 + 11a m + 1a m + 4 + 7a m + 2 − 8am + 14a m − 1 + 5am + 3 + 11a m + 1 ⇒ am + 4 + 5am + 3 + 7am + 2 + 11a m + 1 − 8a m + 14a m − 1a+229. x − 7 x a + 9x a − 1 + 25x a − 2− 19x a − 45x a − 1+ 11x a + 1 − 60x a − 3a+2 a −1 a−2x − 26x − 36x a + 25x + 11x a + 1 − 60x a − 3 ⇒ x a + 2 + 11x a + 1 − 26x a − 36x a − 1 + 25x a − 2 − 60x a − 3 n+1n−230. m − 6m+ 8mn − 3 − 19mn − 5− 5mn − 2 − 6mn − 3 − 9mn − 5 − 8mn − mn − 4mn + 1 − 11mn − 2 + 2mn − 3 − 28mn − 5 − 8mn − mn − 4 ⇒ mn + 1 − 8mn − 11mn − 2 + 2mn − 3 − mn − 4 − 28mn − 5EJERCICIO 22b− a 7. − a + 2b − 3cb− a− a + b − 2c1. 2b − 2a ⇒ − 2a + 2b − 2a + 3b − 5c2. 2x + 3y 8. − 3n + 4m + 5p −x+y + n − m −p x + 4y− 2n + 3m + 4p ⇒ 3m − 2n + 4p3. − 7a + 59. x + 3y − 6z5a−bx−y +z − 2a + 5 − b ⇒ − 2a − b + 5 2x + 2y − 5z4. − x 2 + 6 10. − 5b 2 + 8ab + a 2 −x 2+ 5x 6b 2 − ab − 3a 2 − 2x + 6 + 5 x ⇒ − 2 x + 5 x + 622b 2 + 7ab − 2a 2 ⇒ − 2a 2 + 7ab + b 25. x 2 y + 5xy 2 − 5m2 − n2 + 6mn+ xy 2 −x 3 − m2 + n2 + 3mn 11. x 2 y + 6xy 2 − x 3 ⇒ − x 3 + x 2 y + 6 xy 2− 6m2 + 9mn6.7a 2b + 5ab 212. − 8x 2 + 5x − 4 − 6a 2 b+ 8a 3+ x − 6 + x3a b + 5ab + 8a ⇒ 8a + a b + 5ab223 32 2 − 8x 2 + 6 x − 10 + x 3 ⇒ x 3 − 8x 2 + 6x − 10
• 22. 14m2 − 8n + 1623. y + y + y + 96 3 213.− 14m2− 9 −m 3 − 23y 3+ 5 − 8y 4 + 15y 5 + 8y − 8n + 7 − m3 ⇒ − m3 − 8n + 7 y 6 − 22y 3 + y 2 + 14 − 8y 4 + 15y 5 + 8y ⇒ y 6 + 15y 5 − 8y 4 − 22y 3 + y 2 + 8y + 1414. 8ab + 5bc + 6cd− ab + bc − 6cd 24. x − x + 3x − 5x − 98 6427 ab + 6bc− 36 − 7x 7 − 5x 5 + 23x 3 − 51x15. a − 9a b − b 323 x 8 − x 6 + 3x 4 − 5x 2 − 45 − 7x 7 − 5x 5 + 23x 3 − 51x − 25a 2b + b 3 + 8ab 2⇒ x 8 − 7x 7 − x 6 − 5x 5 + 3x 4 + 23x 3 − 5x 2 − 51x − 45a 3 − 34a 2b+ 8ab 2 25. x 7 − 3x 5 y 2 + 35x 4 y 3 − 8x 2 y 5 + 6016. 6x − 8x y − 6xy 322+ 60x 4 y 3 + x 2 y 5 − y 7 − 90x 3 y 4 + 50xy 6 − xy 2 + 6y 3 − 4 x − 3x y + 95x y − 7 x y + 60 − y 7 − 90x 3 y 4 + 50xy 675 2 4 32 5 ⇒ x 7 − 3x 5 y 2 + 95x 4 y 3 − 90x 3 y 4 − 7x 2 y 5 + 50xy 6 − y 7 + 606x 3 − 8x 2 y − 7xy 2 + 6y 3 − 4 x+317. m2 − 9n + 11c + 14 26. a − 8a x + 1 − 5− m2 − 7n + 8c −d + 5a x + 1 − a x + 2 + 6a x− 16n + 19c + 14 − d ⇒ 19c − d − 16n + 14a x + 3 − 3a x + 1 − 5 − a x + 2 + 6a x ⇒ a x + 3 − a x + 2 − 3a x + 1 + 6a x − 518. 5a + 9a b− 40ab 3 + 6b 443 − 7a 3b + 8a 2b 2 − 5ab 3 − b 4 27. − 8an + 16an − 4 + 15an − 2 + an − 35a 4 + 2a 3b + 8a 2b 2 − 45ab 3 + 5b 4− 7an − 5an − 2 − an − 3 − 8an − 1− 15an + 16an − 4 + 10an − 2 − 8an − 119. x 5 − 8x 4 + 25x 2 + 15 n −1 n−2 ⇒ − 15a − 8a n + 10a + 16an − 4 − 6x 2 + 7 − 6x 3 + 9xx 5 − 8x 4 + 19x 2 + 22 − 6x 3 + 9x 28. 15x a + + 5x a + − 6x a + 41x a −32 1⇒ x 5 − 8x 4 − 6x 3 + 19x 2 + 9x + 22 + 9x a + 2 + 18x a − 1 − 31x a + 1 + x a + 420. − 3xy 4 − 8x 3 y 2 − 19y 5 + 1815x a + 3 + 14x a + 2 − 6x a + 59x a − 1 − 31x a + 1 + x a + 4− 6xy 4 − 25y 5 −x +x y 52 3 ⇒ x a + 4 + 15x a + 3 + 14x a + 2 − 31x a + 1 − 6x a + 59x a − 1− 9xy 4 − 8x 3 y 2 − 44y 5 + 18 − x 5 + x 2 y 3⇒ − x 5 − 8x 3 y 2 + x 2 y 3 − 9xy 4 − 44y 5 + 18 m −1 29. 9a− 21am − 2 + 26m − 3 + 14am − 5 5am − 1 − 12am − 2+ am + 8am − 421.x 3 − 6x 4 + 8x 2 − 9 + 15x− 25x 3+ 18x 2 + 46 − 25x + 11x 514am − 1 − 33am − 2 + 26m − 3 + 14am − 5 + am + 8am − 4 ⇒ am + 14am − 1 − 33am − 2 + 26m − 3 + 8am − 4 + 14am − 5− 24x 3 − 6x 4 + 26x 2 + 37 − 10x + 11x 5⇒ 11x 5 − 6x 4 − 24x 3 + 26x 2 − 10x + 37 30.− 15mx + 3+ 50mx + 1 − 14mx − 6m x − 1 + 8mx − 222. a5− 26a 3b 2+ 8ab 4 − b 5 + 6mx+4+ 23m x+2+ 6mx + 1 + mx − 1 − 8a 4b − a 3b 2 + 15a 2b 3 + 45ab 4 +8 m x+4− 15m x+3+ 23m x+2+ 56m x +1 − 14m − 5mx − 1 + 8m x − 2xa − 8a b − 27a b + 15a b + 53ab − b + 14 5 43 2 2 345
• 23. EJERCICIO 23 11. x − 12− xy − y 21. 1 − a +1x 2 − 1 − xy − y 2 ⇒ x 2 − xy − y 2 − 1 −a+2 12. a 3+62. 0 − 5a 2b + 8ab 2 − b 3− a+8 a 3 − 5a 2b + 8ab 2 − b 3 + 6 − a+8 13. x 3 + y3 −9+ 5 x y − 17 xy22+53. − 3a − a + 5 2 x + 5 x y − 17 xy + y + 5 322 3 − 3a − a − 4 ⇒ − a − 3a − 4 22 14. x 4−14. + 16− 9 x y + 8x y + 15 xy32 23 − 5xy + x − 162 x − 9x 3 y + 8 x 2 y 2 + 15 xy 3 − 1 4 − 5xy + x 2⇒ x 2 − 5xy 15. a 5+ b5 + 11a b − 2a b − 8a b + 4ab42 33 2 45. 1 a + 11a 4b − 2a 2b3 − 8a 3b 2 + 4ab 4 + b5 5 − a 3 + a 2b − ab 2 ⇒ a 5 + 11a 4b − 8a 3b2 − 2a 2b3 + 4ab 4 + b5 1− a + a b − ab ⇒ − a + a b − ab + 13223 2 2 16. x 4+ x2 + 506. x 3 − 5x 3 + 25xx 3 + 8 x 2 y + 6xy 2 x 4 − 5x 3 + x 2 + 25x + 50 2x 3 + 8x 2 y + 6 xy 2 17. y + y − 416 37. a− 9y 5 − 17y 4 + y 3 − 18y 2 + 8a 2b − 6ab 2 + b 3 y 6 + y − 41 − 9y 5 − 17y 4 + y 3 − 18y 2 a 3 + 8a 2b − 6ab 2 + b 3⇒ y 6 − 9y 5 − 17y 4 + y 3 − 18y 2 + y − 418.+ y4 18. a 6+ 9a 4b 2 + a 2b 4 5x 3 y − 7x 2 y 2 + 8 xy 3+ 15a b5− 17a b 3 3 + 14ab 5 + b 6 5x 3 y − 7x 2 y 2 + 8 xy 3 + y 4a 6 + 15a 5b + 9a 4b 2 − 17a 3b 3 + a 2b 4 + 14ab 5 + b 6 19. x + x − 11x4 39. m4 − 5m4 + 18am3 − 7a 2m2 − a 3m + a 4− 5 x + x 2 + 34 − 4m4 + 18am3 − 7a 2m2 − a 3m + a 4 x 4 + x 3 − 16x + x 2 + 34 ⇒ x 4 + x 3 + x 2 − 16 x + 34 20. m 3−110. 16− m2n − 7mn2 + 3n314 − b + a − c − d m3 − m2n − 7mn2 + 3n3 − 1 30 − b + a − c − d ⇒ a − b − c − d + 30
• 24. EJERCICIO 245 32 31.1 2a6. 6 m +9 n21 2121 3 1 23a + ab − b 2 + n + m n − mn24355 28 2 +1 2 1 2 5 3 10 + 9 3 1 2 3 a + ab − b 2 m + n + m n − mn2435 6 45 2 8 3 2 1 2 2 = a + ab − b 51 3 19 3 435⇒ m3 + m2n − mn2 +n62 8 452. 15 3 2 1 342 5 7.a + ab − b2 − xy − yz + 7 3 553 9 5 2 1 1−a − ab+4 2 135 + 5 14 2 8 −xy − yz +5 396−5 2 2−3 4 2 140 a +ab = − xy − yz + 146 5 391 2 1 314 2a − ab − b 2 + = − xy − yz + 15 5914 6 585 33 251 238. x+ xy−ybc86 103.5 3 2 31 3 2 x+xy −2y 2 − bc + ab + cd 5106 4 9 15 + 24 2 50 + 181+ 20 2 18 − 53 2 x +xy − ybc + ab + cd4060 1030 4 939 2 6821 2 39 2 1721 23132=x +xy −y =x +xy −y ⇒ ab +bc + cd40 6010 40 15104 30 9 5 9. a + a− + 32 1 2 a4. a − b 623 7 29742 1+a −a − − a − b + 8 10859 28 + 7 2 10 + 920 − 21 5−8 6+21 a3 + a − a+a− b+ 810 24109 2 15 2 19 1 38 1 =a +3 a −a− =−a− b+ 8 1024109 2 7 4 3 10 . m + 12 mn− 32 n 5 23 275. 9 x −8y55 2 11 25 3 − mn2 − n3+m n+ −y − xy +9218 107 11 21− 20 4+7 3 5 2 1 5 2 30 + 8 2 5 x −y − xy +3m3 + mn2 − n + m n+ 9807 11 367218 538 2 53 51111 = x2 −y − xy +⇒ m3 + m2n +mn2 − n3 + 9807 11 21 367 855 19 2 3 ⇒ x 2 − xy − y +97 40 11
• 25. 3 435 32 4 137 811. x + x3y − xy + y 12. a+ b− c + d5473 258 95 2 21 5 4 7 1 1 7 − x4 − x y + xy 3 − y+b − c + d −83 620 8 9 83−5 4 3 3515 − 7 3 4 − 5 4 112 + 77 +18 +17x + x y − x2y 2 − xy +ya+b−c+d−54 821 6 2 208 9823 5 8 3 1 4 119 89 7= − x 4 + x3y − x2y 2 −xy − y= a+ b− c+ d −54 8216220 89 8 1197 = a+ b− c+ d − 2208EJERCICIO 251.3 2 56. 5 21 2 1a − a a b+ ab −8 6 84357 2 5 3 − a2+ ab − 6− a68 69 − 20 2 511 2 55 22 + 7 2 1+ 18 5 3a − a=−a − aa b+ ab − − a24 6246 883 65 29 2 19 5 3= a b + ab −− a2.8a+ 6b−588 3 61 3 559 19 − a +b ⇒ − a 3 + a 2b + ab2 −2 5 688316 − 130 + 3 1533 a+b−5 =a+b−52 5 2 5 2 35 2 21 7. mn +mn + mn3 − 62 2111433. x + x y − 633 7 2 22m4 −mn + mn37 2 89 − x y92 3 20 − 49 2 2 3 + 2m4 +m n+mn +mn3 − 66−7 21 1156 9 x3 +x y − 6 = x3 − x2y − 6 9 9 2 29 2 2 5= m4 + m3n −m n + mn3 − 611 5694.a+ b− c1 3 2 − a + b− c2 4 3 7 41 3 2 2 2 3 1 42 −14+33+2 175 8.− x y +x y + x y + xy − 7 a+ b− c= a+ b− c8 143 3 2 43243 1 53 3 2 12 x −x y + xy 4 − 27 89 2 515. m + n+ p 1 5 7 4 1− 6 3 2 2 2 3 8 + 3 4 63 + 2 3 62 x − x y+x y + x y +xy −28 14 3249−m − n+ p 1 5 7 4 5 3 2 2 2 3 11 4 652−35−61+ 2 113=x − x y−x y + x y +xy −m+ n+p= − m− n+ p2 814 3 24 9 362 362 1 5 7 4 5 3 2 2 2 3 11 4=x − x y−x y + x y +xy − 7 2 9 2 814 3 24
• 26. 7 5 2 4 212 69. x y+x y − x 3y 3 − x 2 y 4 + xy 5 + y 9 38 137 4 21 2 4 − x6+x y −x y − xy 5 + y69 11 7 5 6 + 7 4 2 1 3 3 11+ 1 2 42 + 13 67 13 4 2 1 3 3 12 2 4 15 6− x6 + xy+x y − x y − x y + y = − x6 + x5 y +x y − x y −x y +y 9 9 8111399811 131 3 7 25 27 3210. x − x y +xy −y −39 811 52 3 1 23x + x y − xy 2− 636 4 1+ 2 3 14 − 3 2 5 − 6 2 7 3 2 + 3011 21732 x −x y+xy − y −= x3 −x y − xy 2 − y 3 −318811 5 188115 3 4 23 2 4 5 611.mn − mn +n107 92 67 4 2 5 2 41 6 3m +mn −mn − n + 13 20143 52 6 6 + 7 4 2 6 + 5 2 4 5 − 3 6 3 2 6 13 4 2 11 2 4 2 6 3m +mn −mn +n + = m +mn −mn + n + 13 20 14 9 5 13 2014 953 57 47 3 2 1 2 31 512. 8 c + 22 c d+ 12c d + c d 2 − 3 d− 355 45 3 2 33 5+c d + c d− cd 4 − d11 6 4 13 3 5 7 + 10 47 + 10 3 2 1 2 3 3 4 13 + 9 5 c +c d+ c d + c d − cd − d − 35 822 12 2 4 39 317 4 17 3 2 1 2 3 3 4 22 5 = c5 +c d+c d + c d − cd − d − 35 822122 439EJERCICIO 26Para los problemas 1 al 14 las literales toman los siguientes valores:a = 1 b = 2 c = 3 x = 4 y = 5 m = 3/2 n = 2/52. a + b331. a − ab2+ 2b 3 + 5a 2b − 6ab 2− 3ab − b 2 a + 3b3 + 5a 2b − 6ab 2 ⇒ a 3 + 5a 2b − 6ab 2 + 3b 33 a 2 − 4ab − b 2 = 13 + 5 ⋅12 ⋅ 2 − 6 ⋅1⋅ 22 + 3 ⋅ 23 = 1+ 5 ⋅ 2 − 6 ⋅ 4 + 3 ⋅ 8 = 12 − 4 ⋅ 1⋅ 2 − 2 2 = 1 − 8 − 4 = − 11 = 1+ 10 − 24 + 24 = 11
• 27. 13. a 223 1 8. 3 m n + 4 mn − 2 n 223 1 5 −a− b+ c 2 31 21 2 1 3 1− 2 1 511 5 mn +mn + n + m3a − b+ c=− a− b + c 6422 2 322 3 4+1 2 3+ 1 251 1 5 1 m n+ mn + m3 = m3 + m2 n + mn2 ⇒ − ⋅1− ⋅ 2 + ⋅ 3 = − − 1 + 56 4 62 2 3 2 3223 5 3 2 3 2 27 5 18 3 4−1− 2 + 10 7= + ⋅ + = + ⋅ + ⋅ == =3 21 26 2 5 2 58 6 20 2 25 2227 3 12 675 + 150 + 48 873=+ + ==8 4 50200 2004. 3m − 5n 2 2 − m2 − 10n 2 − 8mn 9. a5− 3a 2b 4 + b 5 2m2 − 15n 2 − 8mn ⇒ 2m2 − 8mn − 15n 222− a b + 5a b4 2 3 3 3 3 2 2 9 484 = 2 − 8 ⋅ ⋅ − 15 = 2 ⋅ − − 3⋅ a − a 4b2 + 5a 3b 3 − 3a 2b4 + b 55 2 2 5 5 4 105 9 24 1245 − 48 − 2427 = 15 − 14 ⋅ 22 + 5 ⋅13 ⋅ 23 − 3 ⋅12 24 + 25 =−− ===−= 1− 4 + 5 ⋅ 8 − 3 ⋅16 + 32 = 1− 4 + 40 − 48 + 32 = 21 2 5 5 10 105. x 4 − 18x 2 y 2 + 15y 4 10. − ab + 10mn − 8mx16x y3 + 6xy − 9y 4 3 − 15ab x 4 + 16x 3y − 18x 2 y 2 + 6xy 3 + 6y 4− 16ab + 10mn − 8mx 3 2 3 = 4 + 16 ⋅ 4 ⋅ 5 − 18 ⋅ 4 ⋅ 5 + 6 ⋅ 4 ⋅ 5 + 6 ⋅ 543 2 2 3 4= − 16 ⋅1⋅ 2 + 10 ⋅ ⋅ − 8 ⋅ ⋅ 4 2 5 2 = 256 + 80 ⋅ 64 − 18 ⋅16 ⋅ 25 + 24 ⋅125 + 6 ⋅ 625= − 32 + 6 − 48 = − 74 = 256 + 5.120 − 7.200 + 3.000 + 3.750 = 4.926 3 11. a6. a − 7am + m323+ 5am + 5m3 − 8a 2 m 2− 11a 2b + 9ab 2 − b 3 a 3 − 2am2 + 6m3 − 8a 2 m ⇒ a 3 − 8a 2 m − 2am2 + 6m3a 3 − 11a 2b + 9ab 2 − b33 3 2 324 3 9 27 = 13 − 11⋅12 ⋅2 + 9 ⋅1⋅ 22 − 23 = 13 − 8 ⋅ 12 ⋅ − 2 ⋅ 1 + 6 = 1 −− 2⋅ + 6⋅2 2 2 2 48 = 1− 22 + 36 − 8 = 79 81 4 − 48 − 18 + 81 19 = 1 − 12 − + ==2 444 1 4 12. x642 271 2 2 537.a +ab − b2− x − x+385 36 81 1 21 4 2 2 53 − a 2 − ab + b x − x − x+610 643 6 8 4 −1 2 7 − 82 −1 2 1 2 11 1 4 2 2 53a + ab −b = a − ab − b 2= ⋅4 − ⋅4 − ⋅4 +6 8 10281064 36 81 11 2 1 2 4 32 20 3 96 − 256 − 80 + 9 ⇒ ⋅12 − ⋅1 ⋅ 2 − ⋅2 = − −= 4− − + =2 8 102 8 103 6 8 24 1 1 2 10 − 5 − 83231 77 = − − = =− =−=− = −9 85 2 4 52020 248
• 28. 3 2 2 213.x3+x y−xy2 x −1 x5 16 5 14. a + a − ax − 3 + ax − 2 3 33 21 35 6 − x+xy +y 4 525 − ax −1 + 9a x − 3 − a x − 2 4−3 3 3 2 2−3 2 1 3 2 − 5 x − 1 x 5 − 54 x − 3 x + x y−xy + ya +a − a 41652556 1 3 21 2 1 3349 x − 3 ⇒ x3 + x y+xy +y ⇒ ax − ax −1 + a 4165255613 2 1 1 3 3 49 4 − 3 = ⋅ 43 +⋅ 4 ⋅ 5 + ⋅ 4 ⋅ 52 +⋅5 = 14 − ⋅14 − 1 + ⋅14 16 525 5 61 154 125 3 49 + 30 − 18 + 245 257 = ⋅ 64 +⋅16 + ⋅ 25 + =1 − += == 8 17 304 16525 5 6 3030 = 16 + 15 + 20 + 5 = 56EJERCICIO 277. − m + n − pm−n+p1. + ab + b 2 a2 2m − 2n + 2p−m+n−p a2 − 5b 2− a 2 − ab + 4b 2m− n + p0 a 2 + ab − 4b 2 − ab + 4b 28.9ax − a 2x 2 − 5ax + 3a 22.a+8 1− 9ax + 7a 2 + 25 x 2− 25 x 2− 6a 2 −a+6 − 14 6a 2 + 25x 2− 24 x 2 − 5ax − 3a 2 14 − 139.5a 2 + 6a − 4a3 −13. − x+ 4xy 2− 8a + 6 − 2a 3 − 5a 2 + 2a − 2 3 2a 3+ 5x 2 y+ y3 2a 3 + 5a 2 − 2a + 2 − a 3 − 5a 2 + 2a − 3 − x 3 + 5x 2 y + 4xy 2 + y 3 5 x 3 − 9x 2+4x4−1 − 7x y2− 11x − 7x 4 3− 6x 11x 4 + 2x 3 + 9x 2 + 6x − 410.x 3 − 5x 2 y − 4xy 2 − y 3− 11x 4 − 2x 3 − 9x 2 − 6x + 4 12x 4 + 2x 3 + 9x 2 + 6x − 5x 3 − 12x 2 y − 4xy 2 − y 311. 35a 2b − 7ab 2 − 11a3+ b3− 7a − 35a b + 8ab + 6 32 2 7a − ab32+54. − 3m n + 4mn − n 3 235m4− 7a 3+ ab − 52 8a − ab + b + 53233m n − 4mn + 5n3 3 2− 4n3+ 4n3 5m4 − 4n312. − 11n4+ 14n2 − 25n + 85. 8a + 9b − 3c6a 19n3 − 6n2 + 9n − 4 − 7a − 9b + 3c −a− 11n4 + 19n3 + 8n2 − 16n + 4 a5an5− 7n3 + 4n6.a −b +ca +b−c 11n − 19n3 − 8n2 + 16n − 44 − 2a + b − c a −a2a + b − c n5 + 11n4 − 26n3 − 8n2 + 20n − 4
• 29. 20. x 4 − 6x 2 y 2 + y 4x 4 − 2x 2 y 2 + 32y 413. − 6a 3m+ 5am3−6 + 8x y + 31y2 24− x 4 − 2x 2 y 2 − 32y 47a − 5a m − 11a m4 32 2− 6m 4x 4 + 2x 2 y 2 + 32y 407a − 11a m − 11a m + 5am − 6m − 643 2 23421. − 6n + n+ n254a4 − 8a 2m2+ m4+ 7n3 − n2 − 8n − 6− 7a 4 + 11a 3m + 11a 2m2 − 5am3 + 6m4 + 6− 6n5 + n4 + 7n3 − 8n − 6− 6a 4 + 11a 3m + 3a 2m2 − 5am3 + 7m4 + 6− 6n5 + n4 + 7n3 − 8n − 6− 4x 4 y + 13x 2 y 3 − 9xy 4n 6+ 3n4 + 8n3 − 1914.− 6x5 + 8x y3 2+ xy 4 − 2y 5n − 6n + 4n + 15n − 8n − 256 5 43− 6x − 4x y + 8x y + 13x y − 8xy − 2y54 3 22 34522. a5 − 3a 3b2 + 6ab 4 x5 − 30x 3 y 2 + 40xy 4 + y 5+ 22a b + 10a 3b2 − 11ab 4 − b546x 5 + 4x 4 y − 8x 3 y 2 − 13x 2 y 3 + 8xy 4 + 2y 5a 5 + 22a 4b + 7a 3b 2 − 5ab 4 − b 57x 5 + 4x 4 y − 38x 3 y 2 − 13x 2 y 3 + 48xy 4 + 3y 5a 5 + 22a 4b + 7a 3b2− 5ab 4 − b 515. a + b 2a− 5a b4 + 7a b 2 3 − b5a−b− 2a + ba 5 + 17a 4b + 7a 3b 2 + 7a 2b3 − 5ab 4 − 2b 52a b16. 8x +9 8x + 6y + 46y − 5223. 4m3 − 5m2 − 2m− 3m3 − 5m2 + 6m + 48x + 6y + 48 x + 6y + 6− 7m3+ 8m + 4 m4 −517. x2 − 6y2 x − 7 xy + 34y 2 2− 3m − 5m + 6m + 432m − 3m − 5m + 6m − 1 4 32− 7 xy + 40y 29y 2 − 1624. 7a 2 − 11ab + b 22b 2 − 8x 2 − 7 xy + 34y 2 x 2 − 7 xy + 43y 2 − 16− 7a 2 + 11ab + b 2 − 8 +418. 4a + 8ab − 5b22 5a + ab + b22 2b 2 − 8 2b 2 − 4 a 2 − 7ab + 6b 2− 4a 2 − ab + b 225. 3a − 4b + 5c5a 2 + ab + b 2a2+ 2b 2 − 7a + 8b − 11 − 5a + 6b − 2c − 11− a + 2b − 7c− a + b + 2c19. x 3− y3 − 5a + 6b − 2c − 11− 6a + 7b− 11− 14x y + 5xy2 2x − 14x 2 y + 5xy 2 − y 3326. 5a 3 + 14a 2 − 19a + 8a5 + 9a − 1x − 14x y + 5xy − y3 22 3− a4 + 3a 2 −13x 3 − 19y 3a −a5 4+ 5a + 17a − 10a + 6324x 3 − 14x 2 y + 5xy 2 − 20y 3− a 4 + 3a 3 −5a − 2a + 8a + 17a − 10a + 15 4 3 2
• 30. 27. m4 + 10m2n2 + 15n4 5 + y5 29. x − 11m n − 14m n − 3mn + n4 32 2 3 3x y + 21x y + 18x y − y 5 4 3 2 2 3m − 11m n − 4m n432 2 − 3mn + 16n3 4x 5 + 3x 4 y + 21x 3 y 2 + 18x 2 y 36m4 + 7m2n2 + 8mn3 − n4 x 5 + 32x 4 y − 26x 3 y 2 + 18x 2 y 3 − 2xy 4 + y 5− m + 11m n + 4m2n2 + 3mn3 − 16n4 4 3− x 5 − 3x 4 y − 21x 3 y 2 − 18x 2 y 35m + 11m n + 11 n + 11mn − 17n4 m 3 2 23 4 29x 4 y − 47x 3 y 2 − 2xy 4 + y 528. a5 + 4a 3b 2 + 8ab 4 − b5x −1 30. 3a + 6ax− 7a b 4+ 15a b − 25ab + 3b 2 34 5a x − 7a x − 1 + a x − 2 − a 3b2 + 3a 2b3 − 5ab 44a x − a x − 1 + a x − 2a 5 − 7a 4b + 3a 3b2 + 18a 2b 3 − 22ab 4 + 2b 58a x + 2 − 7a x + 1 − a x+ 12 a x − 13a 5 − 6a b − 21ab2 3 4 −6 − 4ax + ax −1 − ax − 2− a + 7a b − 3a b − 18a b + 22ab − 2b54 3 22 3 4 58a x + 2 − 7a x + 1 − 5a x + 13 a x − 1 − a x − 22a + 7a b − 3a b − 24a b + ab 5 4 3 2 2 34− 2b − 6 5EJERCICIO 281. x 2 +5 x−4 x 2 + 2x − 1 6. a2 x− 3x 3− 5a 2 x + 11ax 2 − 11x 32x − 6 −x+6−2 a 3 + 3ax2a − 4a 2 x + 6ax 2 + 8x 33 x + 2x − 122 x + 2x − 3 2a 3 + a 2 x + 3ax 2 − 3x 3a 3 − 9a 2 x + 17ax 2 − 3x 32. 3a − 5b + c 7a + b 4a − 6b − 2ca − b − 3c− 8b − 3c − 7a + 7b + 3ca 3 + a 2 x + 3ax 2 − 3x 3 − a 3 + 9a 2 x − 17ax 2 + 3x 3 4a − 6b − 2c7a − 7b − 3c − 3a + b + c10a 2 x − 14ax 23. x 3+19x + 46x 3 − x 2 +8 5x 3 − x 2 + 7− 3x 2 − x + 1 3x 2 − 8x − 5 6x − x + 832 − 3x + 8 x + 5 26x + 2x 2 − 8x + 33 7. x4 + x2−3a +1 2 a 4 +2a +a32 −x 3− 3x + 5 − 7 x 3 + 8x 2 − 3x + 44. a3−1a −2− a4 −ax 4 − 5x + 4 x2 x 4 −3 a3 + a2 a4 + a− a4 + a3 + a2 − a 2x − x − 4 x + x + 2432x − 7 x + 8 x − 3x + 1 4 325. ab + bc + ac 5ab − 3bc + 4acab − 6bc + 9ac − 92x 4 − x 3 − 4 x 2 + x + 2− 7bc + 8ac − 9 − ab + 3bc + 5ac− 4ab − 9ac − x 4 + 7 x 3 − 8x 2 + 3x − 1 ab − 6bc + 9ac − 94ab+ 9ac − 3ab − 6bc −9x 4 + 6x 3 − 12x 2 + 4x + 1
• 31. 8. m 4− n417m n − 4m n − 7mn3 3 2 2− m4 +617m3n + 2m2n2 − 7mn3 − 81n4 − m4+ 6m2n2 − 80n4− m2n2 + mn3 − 4 m4+ m2n2 − mn3 −217m3n + 2m2n2 − 7mn3 − 81n4 − m4 − m2n2 + mn3 + 2 m4 + 17m3n + 3m2n2 − 8mn3 − 81n4 − 29.+ a3+ a − 7 a −a5 4 − 6a 2+ 8− a 4 − 4a 3 + a 2 a 5 − a 4 + a 3 − 11a 2 − 10a + 27− 5a 2 − 11a + 2616a 3 − 8a 2 − 7a − 15 + a 4 − 12a 3 + 7a 2 + 7a + 15 a 5 − a 4 + a 3 − 11a 2 − 10a + 27 − a 4 + 12a 3 − 7a 2 − 7a − 15 a5− 11a 3 − 4a 2 − 3a + 4210. 3x 2 − y2x 2 − 3xy − y 2 20x 2 − 11xy + 8y 2− 11xy + 9y − 14 2 19x − 8xy + 9y22 − 3x 2 + 11xy − 8y 2 + 143x 2 − 11xy + 8y 2 − 1420x 2 − 11xy + 8y 2 17 x 2 + 1411. a −1a2 −312.a 2 − ab + b 2− a +1 a −43a 2 − 8ab + 7b 2 − a 2 + 9ab + 3b 2− a 2 + ab − 4b20 − 3a + 8− 5a + 11ab − 17b 2 2 − 8ab − 7b 2 a 2 − 2ab + 9b 2 a 2 − 2a + 1 − a 2 + 2ab − 9b2− a 2 + ab − 4b 2− ab + 5b 213. m4 −1− m3 + 8m2 − 6m + 5m5− 16 m5 − 16m4+ 7m2− 19 − m − 7m + 1 2 − 16m + 7m − 3 42− m + m − 7m2 + 13m − 543m4 − m3 + 7m2 − 13m + 5 m5 − 16m4 + 7m2 − 19m5 − 17m4 + m3+ 13m − 2414. x5− y5− 2x y + 5x y − 7 x y43 2 2 3− 3y 5 7x 4 y − x 3 y 2 + 11xy 4− x 5 + 2 x 4 y + 2 x 3 y 2 + 7 x 2 y 3 − 6 xy 4 + 4y 5 + 8 − 7x y 3 2 + 6 xy 4 −8− xy 4−1 7x 4 y − x 3 y 2 + 10xy 4−1x − 2x y − 2 x y − 7 x y + 6xy − 4y − 85 43 2 2 345 7 x y − x y + 10xy − 1 4 3 24 − x + 9x y + x y + 7 x y + 4xy 4 + 4y 5 + 7 54 3 2 2 315. − a+ 7a 4− 8a6− 3a5+ 11a 3 − a 2 +4 − 6a 4 − 11a 3− 2a + 8− 3a 4+ 7a 2 − 8a + 55a 5 − 3a 4 − 7a 3 + 48a 2 − 58a + 13− 5a 3+ 5a − 4a + 1 25a 5 − 7a + 41a − 50a + 8 32 a + 3a 5 − a 4 + 5a 3 − 4a 2 + 14a − 136− a 6 − 3a 5 + a 4 − 5a 3 + 4a 2 − 14a + 13 5a 5 − 3a 4 − 7a 3 + 48a 2 − 58a + 13a 6 + 8a 5 − 4a 4 − 2a 3 + 44a 2 − 44a16. a5 − 7a 3 x 2 + 9+ 18a 3 x 2− 4x 5 − 8− 20a x4+ 21a x − 19ax 2 34− 9a x − 17a x + 11a x 4 3 22 3 + 9a 3 x 2− 7ax 4 + x 5 − 80a5 + 36a − 20a x + 2a x + 21a x − 26ax + x − 71543 22 3 45a − 9a x + a x 5 4 3 2 + 11a x − 4 x2 35+ 28 a 5 − 9a 4 x + a 3 x 2 + 11a 2 x 3− 4 x 5 + 28− a + 20a 4 x − 2a 3 x 2 − 21a 2 x 3 + 26ax 4 − x 5 + 71 511a 4 x − a 3 x 2 − 10a 2 x 3 + 26ax 4 − 5x 5 + 99
• 32. EJERCICIO 29 77 4 325. 12 a 4 a − a3 + a2 −61 312 751. a +b a3 3 2 2 3 41 12 4− a + a −6a − a+ 23 15 7545 3− a + b− a − b7 4 3 3 2 27+9 4 3 3 2 2 118 − 1 34 34a − a + a −6 a − a + a − a− 127 5127 55 3 3−22+39−4 5 a+ b a− b 4 4 3 3 2 2 = a − a + a − 1 a−173412 4 37 55 31 5 55 = a+ b=a− b3 4124 121 5 26. − x+ y− z y − 234 9 5 31 3 3 2 12 1 5 132. a−6a + a−y− z +3x− y+z− 3 82595 2 9 20535 3 3 2 3 − a3 + a2a − a − a+6 16 −15+8 1132 + 156565 8 −x+y− z+3 x+z−5333+5 33 2 9 20 2205 − a3 + a2 + a − 6 a− a+6 1513 1 1317658 6 8=− x+ y−z+3= x+z−4 3 2920 2 20 5= a3 − a + 63 8 3 7 3 233. a +3b a+b +6 7. − a b + ab2 − b3 5 3 24 2 2 111 252 3 − a − b+6− a+ba b − ab 2+ b 5 3 56863 5−29 −2 3 −114 + 112 − 1 2 9 − 10 2 3 − 2 3 a+b+6a+b+6− a b+ab −b5 3 56 8 123372511 11 = a+ b+6 = a+ b+6 = − a 2b − ab 2 − b 35352 8123 1 3 1 3 a − b 2 3 1 33 214. 3 x −7x+ 5 11 2 a b+ 1 1 ab 2 + b 3 812 31 2 2x − x+61 3 11 21 149 a + a b+ab 2 28 12 1 3 6 −1 2 21+ 30 x −x − x+ 3 14 951 3 5 2 2 31 = x − x − x+ 1 221 1 133 149 5 8. a − b b +c a+ b − c2 935 2 951 351 11 − 5 3 xb − c − b − c− b−c 63 59 10 9 10 1 35 2 23112−336−5 2 −1 1 6 +1 − x +x + x− a− b− cb+ c a −c 3 149 5 2 9 5 910 2105+2 3 5 2 21 1 3 1 1 1 7 − x +x + x− 31= a+ b − c = b+c= a− c 6 14 95 2 9 5 910 210 7 3 5 2 2 =− x +x + x−6 5 1 614 9
• 33. 1 3 1 2 11 2211 319 2219. 3 a + 8 a + 54a− 3 a+43 a −40 a −3a +83 31 1 3 29 2 1119 231 − a2− a−a −a − − a3 + a +a −5 4 10 3 40 83404 101 3 5 − 24 2 32 −11 3 10 − 29 2 22 −18−9 10 − 8a + a − a+a + a − a+a+−3 40410 3403812 801 3 19 2 3 1 1 3 19 2 2 112 1 1= a −a − a+ = a −a − a+ =a+ = a+3 404 10 3403 8 1280 12403 2 5 2 2 2 212 23 2 713 2110. 5 x − 6 xy +9y9x+ 9 xy −3y− 5 x + xy +36 y+23 1 1 17 2 22 3 2 13 2 7 11− xy − y2 +x −xy− y −x − xy − y 2 +2 3 4 459 2 253943 2 10 + 18 2−3 2 110 + 17 2 1− 22 4+9 2 1 39 − 2 2 2 + 1x −xy +y + x +xy −y −y +5 12 9 4 45 9 6 2 18 43 2 281 2 127 2 2113 2 1 37 2 3= x − xy − y + = x − xy −y − =y +5 12 9 4 45 96218 43 2 7 1 2 13 2 713 2 1= x − xy − y + = x − xy −y −5 3 94 53622 1 31 21 2 13 2 3 3 73 − a b +−− a b + ab 2 − b 3 −11. 7 a 5b 24ab54 8 210 331 3 5 1 2 312 3 3 1 3− a 2b + ab 2 + b − a 2b + ab − b 3 − − a 3 + a 2b − ab 2 +b 48 10 4 8 227 4 8102 3 3 23 2 −1 32−5 22 +1 2 3 3 2 + 5 2 315 − 1 3 7a − a b + ab 2 −b a b+ab − b −−a− b −74 8 104 82107 10 102 3 3 23 21 3 3 23 2 3 3 7 2 3 14 3 72 3 7 3 7= a − a b + ab −b = − a b + ab − b −=− a −b −=− a − b −74 8 10 482 10 7 10 10 75 10 1 2 2112.mn − mn3 −n4 34 2 4 3 2 2 2 5 4 5 42 m + m3n − mn+ n m − n4 7 5 5 3145 1 47 31 2 2 2 4 5 4 1 311 2 2 1 m −mn + mn− n−m − m n−m n + mn314 204 3144 6044 + 1 4 12 − 7 3 20 − 24 + 15 2 2 13−5+2 4 1 3 11 2 2 1 2 m +m n+ m n − mn3 −n− m n−m n + mn3 − n4 142060 43 4604 5 5 4 5 3 11 2 2 1 0=m +m n+m n − mn3 − n414 2060 4 3 5 4 1 3 11 2 2 1=m + m n+ m n − mn 314 4 60 4
• 34. 1 113. x+ y2 3 3 1 y − z 4 6 21 z +m 5 541 1311371 1 3 − m+ n+− x−y−z+ m − n −2 3821230 4 3 814+95 − 121− 2 13 113 71140 − 3x+ y−z+m + n+ − x−y−z+ m − n +2 12304382 1230 4381 1371 1 3 113 7 1 1 37= x+ y+z− m + n+=− x−y− z+ m − n +2 1230 4 3 8 212 304 385 4 1 3314. a + a− a6 25 2 2 3 − a − a +5 3 83 4 3 31 2 2 11 41 3 1 2 152− a − a+ a −a −a − a +8 46 3 24 122 331 339 31 33+ a+a+− a4+a −640 1112820 − 9 4 6 − 9 + 2 3 4 − 1 2 24 + 15 − 39165 − 22 + 911− 24 41 1216 − 99.a + a − a − a+a − a2 +24 12640 3324 2 26411 4 1 3 3 2 0152 11 4 1 3 1 2 152 .13 4 1 2 1117=a −a − a −a+=a − a − a +=−a − a +24 12 6 40 33 24 12 2 33242264EJERCICIO 301. x3 − x2+5 4. x 3 − 4x 2 +87. 5a + 8ab − b − 113 2 3 − x + x + 3x − 5 − 632− x 3 + 4 x 2 + x − 13− a3+ b33x −6x− 5 4a 3 + 8ab 2 − 11 Rta. − x + x + 3x − 11 32Rta. x − 4 x − x + 1332Rta. 5a + 8ab − b3 − 1132 1 12. − 5a + 9b − 6c5.m4− 3mn3 + 6n48.x− y−4 2 3 5a − 9b + 6c + 8x + 9− m4 + 4m2n2 + 3mn3 − 6n4 − 81 1− x+ y 8x + 9 4m2n2 −8 2 3 Rta. 5a − 9b + 6c + 8x + 9 Rta. m − 4m2n2 − 3mn3 + 6n4 + 84 −4 1 13. a3 − b3 6. 4x + 5x − 5x − 232Rta. x− y−4 2 3 − a 3 − 8a 2b + 5ab2 − 3b3− 5x 2 − 4 x + 8 − 8a 2b + 5ab2 − 4b 34x 3 − 9x + 6 Rta. − a − 8a b + 5ab − 3b3 22 3Rta.4x 3 + 5x 2 − 5x − 2
• 35. 9. 5x 2 − 7 xy − 8y 2 10. n311. 0 − 5x + 7 xy + 8y + 12 2− 9m + 8m n − 5mn + n3 2 23− a + 5a − 831 − 9m + 8m n − 5mn + 2n3 2 23− a 3 + 5a − 8 Rta. − 5 x + 7xy + 8y + 12 210m − 8m n + 5mn − 2n3 2 23Rta. 0m3Rta. 10m3 − 8m2n + 5mn2 − 2n3EJERCICIO 311. x − ( x − y) 6. a + (a − b) + (− a + b)11. x + y + ( x − y + z ) − ( x + y − z) = x− x+ y = a+ a−b− a+b = x+ y+ x− y+ z− x− y+ z =y= 2a − a = a= x − y + 2z(2. x + − 3x − x + 522) 7. a + − b + 2a − a − b2 22 2212. a − (b + a ) + (− a + b) − (− a + 2b) = x − 3x − x + 52 2 = a − b + 2a − a + b2 2 2 2 2= a − b − a − a + b + a − 2b = − 3x + 5= 3a − a = 2a2 2 2= − 2b3. a + b − (− 2a + 3) 8. 2a − {− x + a − 1} − {a + x − 3}() (13. − x 2 − y 2 + xy + − 2 x 2 + 3xy − − y 2 + xy ) [ ] = a + b + 2a − 3= 2a + x − a + 1 − a − x + 3= − x + y + xy − 2 x + 3xy + y − xy 22 2 2 = 3a + b − 3= 1+ 3= 4 = − 3x 2 + 3xy + 2 y 24. 4m − (− 2m − n)2 2 2(9. x + y − x + 2 xy + y + − x + y 2 22) [ ] 2 [ 2 2]{14. 8x + − 2 xy + y − − x + xy − 3 y − x − 3xy2 2} ( ) = 4m + 2m + n= x + y − x − 2 xy − y − x + y2 2 2 2 2 2 = 8x − 2 xy + y + x − xy + 3y − x + 3xy 22 2 2 2 = 6m + n = − x − 2 xy + y2 2= 8x 2 + 4 y 25. 2 x + 3 y − (4 x + 3 y)10. (− 5m + 6) + (− m + 5) − 615. − (a + b) + (− a − b) − (− b + a ) + (3a + b) = 2 x + 3y − 4 x − 3 y = − 5m + 6 − m + 5 − 6 = − a − b − a − b + b − a + 3a + b = − 2x = − 6m + 5 =0EJERCICIO 32[1. 2a + a − (a + b) ] [2. 3x − x + y − (2 x + y) ] [ 3. 2m − (m − n) − (m + n)][ = 2a + a − a − b ] [= 3x − x + y − 2 x − y] [= 2m − m − n − m − n] = 2a + a − a − b = 3x − x − y + 2 x + y= 2m − m + n + m + n = 2a − b = 4x= 2m + 2n
• 36. [() (4. 4 x + − x − xy + − 3 y + 2 xy − − 3x + y2 22 22 ) ( )][11. − (− a + b) + − (a + b) − (− 2a + 3b) + (− b + a − b)][ = 4 x + − x + xy − 3 y + 2 xy + 3x − y2 2 2 22 ][ = a − b + − a − b + 2a − 3b − b + a − b] = a − b − a − b + 2a − 3b − b + a − b = 4 x 2 − x 2 + xy − 3 y 2 + 2 xy + 3x 2 − y 2 = 3a − 7b = 6 x 2 + 3xy − 4 y 25. a + {(− 2a + b) − (− a + b − c) + a} {[12. 7m − − m + 3n − 5 − n − − 3 + m2 2 2() ()] }− (2n + 3) = a + {− 2a + b + a − b + c + a} {[ = 7m2 − − m2 + 3n − 5 + n + 3 − m2]} − 2n − 3 = 7m − {− m − 3n + 5 − n − 3 + m } − 2n − 3 = a − 2a + b + a − b + c + a 222 =a+c = 7m2 + m2 + 3n − 5 + n + 3 − m2 − 2n − 3[6. 4m − 2m + (n − 3) + − 4n − (2m + 1)] [] = 7 m2 + 2 n − 5[ = 4m − 2m + n − 3 + − 4n − 2m − 1] [ ] = 4m − 2m − n + 3 − 4n − 2m − 1 {[13. 2a − (− 4a + b) − − − 4a + (b − a ) − (− b + a )]} = − 5n + 2 {[ = 2a + 4a − b − − − 4a + b − a + b − a ]} = 6a − b − { 4a − b + a − b + a}[ (7. 2 x + − 5x − − 2 y + {− x + y} )] = 6a − b − 4a + b − a + b − a[ = 2 x + − 5x − ( − 2 y − x + y ) ]=b[ = 2 x + − 5x + 2 y + x − y ] = 2 x − 5x + 2 y + x − y = − 2x + y ( [ {14. 3x − 5 y + − 2 x + y − (6 + x) − (− x + y)}])( [ = 3x − 5 y + − 2 x + {y − 6 − x} + x − y ]){ [8. x − − 7 xy + − y + − x + 3xy − 2 y 22( 22 )] }= 3x − (5 y + [− 2 x + y − 6 − x + x − y] ) = 3x − (5 y − 2 x + y − 6 − x + x − y){ [ = x 2 − − 7 xy + − y 2 − x 2 + 3xy − 2 y 2]} = 3x − 5 y + 2 x − y + 6 + x − x + y = x 2 − {− 7 xy − y 2 − x 2 + 3xy − 2 y 2 } = 5x − 5y + 6 = x 2 + 7 xy + y 2 + x 2 − 3xy + 2 y 2 = 2 x 2 + 4 xy + 3y 2[{15. 6c − − (2a + c) + − (a + c) − 2a − (a + c) + 2c} ][ = 6c − − 2a − c + { − a − c − 2a − a − c } + 2c][ {9. − (a + b) + − 3a + b − − 2a + b − (a − b) + 2a }][ = 6c − − 2a − c − a − c − 2a − a − c + 2c ][ = − a − b + − a + b − {− 2a + b − a + b}] = 6c + 2a + c + a + c + 2a + a + c − 2c[ = − a − b + − a + b + 2a − b + a − b ]= 6a + 7c = − a − b − a + b + 2a − b + a − b = a − 2b( ) [ {16. − 3m + n − 2m + − m + 2m − 2n − 5 ())} − (n + 6)]( = − 3m − n − [ 2m + {− m + (2m − 2n + 5)} − n − 6]{10. (− x + y ) − 4 x + 2 y + − x − y − ( x + y )[]} = − 3m − n − [2m + {− m + 2m − 2n + 5 } − n − 6] = − x + y − {4 x + 2 y + [− x − y − x − y ] } = − 3m − n − [2m − m + 2m − 2n + 5 − n − 6] = − x + y − {4 x + 2 y − x − y − x − y} = − 3m − n − 2m + m − 2m + 2n − 5 + n + 6 = − x + y − 4x − 2 y + x + y + x + y = − 6m + 2n + 1 = − 3x + y
• 37. {[()]17. 2a + − 5b + (3a − c) + 2 − − a + b − (c + 4) − (− a + b) }[ {( ) [ ( ) ( 23. − x + − x + y − − x + y − z − − x + y − y )] }]= − [ x + {− x − y − [− x + y − z + x − y ] − y}]= 2a + {− [5b + 3a − c + 2 − (− a + b − c − 4) ] + a − b}= 2a + {− [5b + 3a − c + 2 + a − b + c + 4] + a − b}= − [ x + {− x − y + x − y + z − x + y − y}]= 2a + {− 5b − 3a + c − 2 − a + b − c − 4 + a − b}= − [x − x − 2 y + z ]= 2a − 5b − 3a + c − 2 − a + b − c − 4 + a − b= − x + x + 2y − z = 2y − z= − a − 5b − 6[ { () ( ) [ ( ) ] }] 24. − − a + − a + a − b − a − b + c − − − a + b[()] {18. − − 3x + − x − (2 y − 3) + − (2 x + y ) + (− x − 3) + 2 − ( x + y) }= − [ − a + {− a + a − b − a + b − c − [a + b] }]= − [− 3x + (− x − 2 y + 3)] + {− 2 x − y − x − 3 + 2 − x − y}= − [− a + {− a − c − a − b}][]= − − 3x − x − 2 y + 3 − 2 x − y − x − 3 + 2 − x − y= 3x + x + 2 y − 3 − 4 x − 2 y − 1= − [− a − a − c − a − b ] = 3a + b + c=−4 EJERCICIO 33[][ ] {[19. − − (− a ) − + (− a ) + − − b + c − + (− c)] [ ]}[ ] {[ ]} = − [a] − − a + b − c − − c 1. a − b + c − d = − a + a + {b − c + c} (= a + −b+ c− d ) = b− c+ c 2. x − 3xy − y + 62 2 =b = x 2 + (− 3xy − y 2 + 6){[ ]} { [20. − − − (a + b) − + − (− b − a) − (a + b)]}3. x 3 + 4 x 2 − 3x + 1 = − {− [ − a − b] } − { + [ b + a] } − a − b= x 3 + ( 4 x 2 − 3x + 1) = − {a + b} − {b + a} − a − b 4. a 3 − 5a 2b + 3ab 2 − b 3 = − a− b− b− a − a− b = a 3 + ( − 5a 2b + 3ab 2 − b 3 ) = − 3a − 3b 5. x − x + 2 x − 2 x + 1 4 3 2{[]} { []} [ {21. − − − (a + b − c) − + − (c − a + b) + − − a + (− b)}]= x 4 − x 3 + ( 2 x 2 − 2 x + 1) = − {− [− a − b + c] } − {+ [− c + a − b] } + [− {− a − b}] 6. 2 a + b − c + d [ = − {a + b − c} − {− c + a − b} + a + b ] (= 2a − − b + c − d ) = − a− b+ c+ c− a+ b+ a+ b = − a + b + 2c7. x + x + 3x − 4 3 2 = x 3 − (− x 2 − 3x + 4)[ {22. − 3m + − m − n − m + 4( ( ))}+ {− (m + n) + (− 2n + 3)}] 8. x 3 − 5 x 2 y + 3 xy 2 − y 3 = − [ 3m + {− m − (n − m − 4)} + {− m − n − 2n + 3}] = x 3 − (5x 2 y − 3xy 2 + y 3 ) = − [3m + {− m − n + m + 4} − m − n − 2n + 3 ] 9. a − x − 2 xy − y 2 2 2 = − [3m − m − n + m + 4 − m − n − 2n + 3] = a 2 − ( x 2 + 2 xy + y 2 ) = − 3m + m + n − m − 4 + m + n + 2n − 3 = − 2m + 4n − 7 10. a + b − 2bc − c2 22= a 2 − (− b 2 + 2bc + c2 )
• 38. EJERCICIO 341. x + 2 y + ( x − y )6. − 2a + (− 3a + b) [= x − − 2 y − (x − y) ][ = − 2a − (− 3a + b) ]2. 4m − 2n + 3 − (− m + n) + (2m − n) [= 4m − 2n − 3 + (− m + n) − (2m − n)] 2 (7. 2 x + 3xy − y + xy + − x + y 2 ) (22 )[ = − − 2 x 2 − 3xy + ( y 2 + xy) − (− x 2 + y 2 )]3. x − 3xy + x − xy + y 2 [( ) ]2 2= x2 − {3xy − [( x − xy) + y ] }2 28. x 3 − − 3x 2 + 4x − 2 []4. x 3 − 3x 2 + − 4 x + 2 − 3x − 2 x + 3( )= − − x 3 + − 3x 2 + 4 x − 2 { } [[ ]= x 3 − 3x 2 − − 4 x + 2 + 3x + (2 x + 3) ] {[ ( )] }5. 2a + 3b − − 2a + a + b − a9.[m − (3m + 2m + 3)]+ (− 2m + 3)42= − {− [ m − (3m + 2m + 3)] − (− 2m + 3)}= 2a − [− 3b + {− 2a + [a + (b − a )] }] 4 2EJERCICIO 3517. ambn ⋅− ab = − am + 1bn + 11. 2 ⋅ − 3 = − 618. − 5ambn ⋅− 6a 2b3 x = 30am + 2bn + 3 x2. − 4 ⋅− 8 = 3219. xmync ⋅ − xmync x = − xm + myn + nc1+ x = − x 2my 2nc1+ x3. − 15 ⋅16 = − 24020. − mxna ⋅− 6m2n = 6mx + 2na + 14. ab ⋅− ab = − a1+ 1b1+ 1 = − a 2b25. 2x 2 ⋅− 3x = − 6x 2 + 1 = − 6x3EJERCICIO 366. − 4a 2b ⋅ − ab 2 = 4a 2 + 1b1+ 2 = 4a 3b37. − 5x3 y ⋅ xy 2 = − 5x3 + 1y1+ 2 = − 5x 4 y 3 1. am ⋅ am + 1 = am + m + 1 = a 2m + 18. a 2b 3 ⋅ 3a 2 x = 3a 2 + 2b 3 x = 3a 4b3 x 2. − xa ⋅ − x a + 2 = x a + a + 2 = x 2a + 29. − 4m2 ⋅− 5mn2p = 20m2 + 1n2p = 20m3n2p 3. 4anb x ⋅− ab x + 1 = − 4an + 1b x + x + 1 = − 4an + 1b 2 x + 110. 5a y ⋅− 6x = − 30a x y 22 2 24. − a n + 1b n + 2 ⋅ a n + 2b n = − a n + 1+ n + 2 bn + 2 + n = − a 2n + 3b 2n + 211. − x2 y3 ⋅− 4y3 z4 = 4x2 y 3 + 3 z4 = 4x2 y 6 z4 5. − 3an + 4bn + 1 ⋅ − 4an + 2bn + 3 = 12a 2n + 6b2n + 412. abc ⋅ cd = abc1+ 1d = abc 2d6. 3x 2 y 3 ⋅ 4x m + 1y m + 2 = 12x 2 + m + 1y 3 + m + 2 = 12xm + 3 y m + 513. − 15x 4 y3 ⋅− 16a 2 x 3 = 240a 2 x4 + 3 y 3 = 240a 2 x7 y 3 7. 4x a + 2b a + 4 ⋅ − 5xa + 5ba + 1 = − 20x 2a + 7b 2a + 514. 3a 2b3 ⋅− 4x 2 y = − 12a 2b3 x 2 y8. ambnc ⋅ − amb 2n = − am + mbn + 2nc = − a 2mb3nc15. 3a 2bx ⋅ 7b3 x 5 = 21a 2b1+ 3 x1+ 5 = 21a 2b 4 x 69. − xm + 1y a + 2 ⋅− 4xm − 3 y a − 5 c 2 = 4x2m − 2 y 2a − 3c 216. − 8m2n3 ⋅ − 9a 2mx 4 = 72a 2m2 + 1n3 x 4 = 72a 2m3n3 x 410. − 5manb − 1c ⋅− 7m2a − 3nb − 4 = 35m3a − 3n2b − 5c
• 39. EJERCICIO 37 3 m2 3 1 3 m+1 3 1 2 4 31 44 528. −a ⋅ − ab3 = ⋅ am + 1b 3 =a b1. a ⋅ a b = ⋅ a 5b =a b = a 5b45 2 510 25 2 5 105 5 m n 3 3 2 7 2 3 9.a b ⋅−ab 2c2. − m n ⋅−am610 714 1 1 1 37 2 5 21 2 5 3 2 5= − ⋅ am + 1 bn + 2 c = − am + 1bn + 2 c = − ⋅−a m n=a m n=amn2 24 7 14 98142 x m +1 3 x −1 m 2 2 3 3 2 4 6 2 6 4210. −a b ⋅− a b3. x y ⋅− a x y = −a x y = − a2x 6y 4 95 3 5155 2 1 2 x − 1 2m + 1 2 2 x − 1 2m + 1=⋅ ab=ab 1 3 4 4 3 24 3 5 5 1 3 5 53 5 154. − m n ⋅− a m n =amn =amn 8 540 10 3 m n4 12 3m 2n 3 3m 2n7 2 314 4 111. a b ⋅ − a 2mbn = −a b =−a b5. − abc ⋅ a = −a bc = − a 4bc 85 40108 756 42 x +1 x − 3 244 x − 3 2 3 3 45 31 12. − a b c ⋅− a b6. − x y ⋅ − a 2by 5 = a 2bx 3y 9 = a 2bx 3 y 9 11 7 56 62 48= 2 ⋅ a 2 x − 2b x − 1c 2 = a 2 x − 2b x − 1c 2 133 m+1 1 m+1 777. a ⋅ am =a= a 35 15 5EJERCICIO 38 3 31 x a 8. −m ⋅− 5a 2m ⋅−am 5 101. a ⋅− 3a ⋅ a 2 = − 3a1+ 1+ 2 = − 3a 415 2 + x 3 +1+ a 3 x+2 a+4=−a m =−a m2. 3x 2 ⋅− x 3 y ⋅ − a 2 x = 3a 2 x 2 + 3 +1y = 3a 2 x 6 y 50103. − m2n ⋅− 3m2 ⋅− 5mn3 = − 15m2 + 2 + 1n1+ 3 = − 15m5n4 9. 2a ⋅− a 2 ⋅ − 3a 3 ⋅ 4a = 24a1+ 2 + 3 + 1 = 24a74. 4a 2 ⋅− 5a 3 x 2 ⋅− ay 2 = 20a 2 + 3 +1x 2 y 2 = 20a 6 x 2 y2 10. − 3b 2 ⋅ − 4a 3b ⋅ ab ⋅− 5a 2 x= − 60a 3 + 1+ 2 b 2 + 1+ 1x = − 60a 6b 4 x5. −am ⋅ − 2ab ⋅− 3a 2b x = − 6am +1+ 2b1+ x = − 6am + 3b x + 1 1 3 2 23 6 2 + 4 3 +1 1 11. a mb x ⋅− a 2 ⋅ − 2ab ⋅− 3a 2 x6. x ⋅− a x ⋅− a 4m =a x m = a 6 x 4m 2 35 30 5= − 6a m + 2 + 1+ 2b x + 1x = − 6am + 5b x + 1x 2 m 3 2 4 1 23 10 3 3 27. a ⋅ a b ⋅− 3a 4b x + 112. − x y ⋅− xy 2 ⋅− x ⋅− x y 3 4 253418 m + 2 + 4 4 + x + 136 2 + 1+ 3 + 2 1+ 2 + 1 3 8 4 =−ab= − a m + 6b x + 5 = xy= x y1228 4EJERCICIO 394. a − 4a + 6a32 2. 8x 2 y − 3y 23. x − 4x + 321. 3x 3 − x 2 − 2x2ax 3 − 2x3ab − 6x + 2x4 316ax 5 y − 6ax 3 y 2− 2x 3 + 8 x 2 − 6 x3a 4b − 12a 3b + 18a 2b
• 40. 5. a − 2ab + b 2 213. x 3 − 3x 2 + 5x − 6− ab− 4x 2 − a 3b + 2a 2b 2 − ab 3− 4 x 5 + 12 x 4 − 20x 3 + 24 x 26. x − 6 x − 8x5 314. a − 6a x + 9a x − 8 432 22 2 3a x 33bx 3a 2 x 7 − 18a 2 x 5 − 24a 2 x 33a 4bx 3 − 18a 3bx 4 + 27a 2bx 5 − 24bx 37.m4 − 3m2n2 + 7n4n+ 315. a − 3a n + 2 − 4a n + 1 − an − 4m3 x − an x 2 − 4m7 x + 12m5n2 x − 28m3n4 x− a 2n + 3 x 2 + 3a 2n + 2 x 2 + 4a 2n + 1x 2 + a 2n x 28. x − 4x y + 6 xy32 216. x 4 − 6 x 3 + 8 x 2 − 7x + 5 ax 3 y− 3a 2 x 3 ax 6 y − 4ax 5 y 2 + 6ax 4 y 3 − 3a 2 x 7 + 18a 2 x 6 − 24a 2 x 5 + 21a 2 x 4 − 15a 2 x 39.a − 5a b − 8ab 3 2217. − 3x + 5x y − 7 xy − 4y322 3 − 4 a 4m 222 5a xy − 4a 7m2 + 20a 6bm2 + 32a 5b 2m2− 15a 2 x 4 y 2 + 25a 2 x 3 y 3 − 35a 2 x 2 y 4 − 20a 2 xy 5m −110. a − am + am − 218. x a + 5 − 3x a + 4 + x a + 3 − 5x a + 1 − 2a− 2x 2− 2a m + 1 + 2a m − 1+ 1 − 2a m − 2 +1− 2x a + 7 + 6x a + 6 − 2 x a + 5 + 10x a + 3= − 2a m + 1 + 2a m − 2a m −1m+1 19. a 8 − 3a 6b 2 + a 4b 4 − 3a 2b 6 + b 811. x + 3 xm − x m − 1 2m − 5a 3 y 23x− 5a11y 2 + 15a 9b 2 y 2 − 5a 7b 4 y 2 + 15a 5 b 6 y 2 − 5a 3b 8 y 2 3 x 3 m + 1 + 9 x 3m − 3 x 3m − 1m −1 n + 2 m−2 n+4 m − 1 n +1 m−2 n+ 220. a b + 3a b − a b m n + a m − 3b n + 612. a b + a b − a b m n4a mb 3 3a 2b4a 2 mb n + 3 + 12a 2 m −1b n + 5 − 4a 2 m − 2b n + 7 + 4a 2 m − 3b n + 9 3a m + 2bn + 1 + 3am + 1bn + 2 − 3a mbn + 3EJERCICIO 4012 3 1221 2a− b23 a− b+ c a2 + ab − b 21. 2 3 2. 3 a − 4 b3.5 654. 5 3 92 25 2 3a 2 xa2 3− ac5− a b 3 3 6 2+23 62 1+ 2 4 215 1+ 1 2 510 2 + 1ax + a2 + 1bx − a 2b 2 x a−a b4 6 3 1+ 1− a c +abc 2 − 53 9 10 15 − a3 + 1b +a b 1518 15ac91262 1 3 4 252 = a 4 x + a3bx − a 2b 2 x = a − a b4 41 3 2= − a 2c 2 +abc 2 − ac 3 53 515 =− a b+ a b 18392
• 41. 1 2 2 1 1 2 1 2 1 2 1 25. x − xy − y 2a − b + x − y 354 23 4 55 3 3− a 2m y8 25 2+ 25 2 2 5 2 2 5 2 2 3 2 3 6 3 8. −a m+ a b m−a mx +a my x y −xy 3 + 1 − y 2 + 3 16243240 6 1085 4 5 2 2 5 2 2 1 2 2=−a m+a b m−a mx + a my 13 31624328 = x 2 y 3 − xy 4 − y 5 25 82 3 1 25 1 9. m + m n − mn2 − n36. 3a − 5b + 6c 3 26 93 2 3 3 2 3 −a x mn 10 4 9 2 + 1 3 15 2 3 18 2 3 6 3 + 2 3 3 2 + 2 1+ 3 15 1+ 2 2 + 3 3 2 3 + 3 −a x + a bx −a cx m n + m n − m n − mn10 1010 128 2436 9 3 3 3 2 3 9 2 31 351 =−a x + a bx − a cx= m5n3 + m4 n4 − m3n5 − m2n610 25 2 88 12 2 4 2 2 1 4 2 6 1 4 2 3 2 4 1 67. x −x y + yx − x y + x y −y 9 3 53 510 3 3 4 5 x y− a3x 4 y3 7 76 4 +3 4 3 2 + 3 2 + 4 3 3 4 + 410 3 6 + 4 3 5 3 4 + 4 2 + 3 15 3 2 + 4 4 + 3 5 3 4 6 + 3x y − x y + x y10. − a x y + a x y − a x y +a x y 63 721 3521 3570 2 7 4 3 5 6 1 3 8 2 5 3 1 3 4 9 = x y − x y + x y= − a 3 x10 y 3 + a 3 x 8 y 5 − a 3 x 6 y 7 +a x y 21777 21714EJERCICIO 411. a + 3 3. x + 5 5. − x + 37. 3x − 2 y a −1 x−4−x+52x + y a 2 + 3a x + 5x 2 x 2 − 3x6x 2 − 4 xy − a−3 − 4x − 20− 5x + 15+ 3xy − 2 y 2 a 2 + 2a − 3 x + x − 20 2 x 2 − 8x + 15 6x 2 − xy − 2 y 22. a − 3 4. m − 6 6. − a − 28. 5x − 4y a +1 m−5−a −3 − 3x + 2y a 2 − 3a m2 − 6ma 2 + 2a− 15x 2 + 12xy a−3 − 5m + 30+ 3a + 6+ 10xy − 8y 2 a − 2a − 3 2m − 11m + 30 2 a 2 + 5a + 6− 15x 2 + 22xy − 8y 2
• 42. 9. 5a − 7b11. − a + b 13. − 9m + 8na + 3b8a − 4b6m + 4n 5a 2 − 7ab− 8a 2 + 8ab − 54m2 + 48mn + 15ab − 21b 2+ 4ab − 4b2 − 36mn + 32n2 5a 2 + 8ab − 21b2 − 8a 2 + 12ab − 4b2− 54m2 + 12mn + 32n210. 7x − 312. 6m − 5n 14. − 7y − 32x + 4m−n2y − 1114x 2 − 6x 6m2 − 5mn− 14y 2 − 6y + 28x − 12− 6mn + 5n 2 + 77y + 3314x + 22x − 122 6m − 11 + 5n 2mn2− 14y + 71y + 33 2EJERCICIO 421. x + xy + y5. a + a − a9. m − m + m − 22 23 2 3 2 x−ya −1am + a x 3 + x 2 y + xy 2 a 4 + a3 − a2 am4 − am3 + am2 − 2am− x y − xy − y 2 23 −a −a32 +a + am3 − am2 + am − 2a x3− y3 a4− 2a 2 + aam4 − am − 2a 6. m + m n + n10. 3a − 5ab + 2b 42 242. a − 2ab + b22 2 2 a −b m −n 224a − 5b a 3 − 2a 2b + ab 2m6 + m4n2 + m2n412a 3 − 20a 2b + 8ab 2− a 2b + 2ab 2 − b 3 − m4n2 − m2n4 − n6 − 15a 2b + 25ab 2 − 10b 3 a 3 − 3a 2b + 3ab 2 − b 3 m6− n612a 3 − 35a 2b + 33ab 2 − 10b 3 7. x − 2x + 3x − 1 3 23. a + 2ab + b 11. 5m − 3m n + n22 42 24 a +b 2x + 3 3m − n a 3 + 2a 2b + ab 2 2x 4 − 4 x 3 + 6x 2 − 2 x15m5− 9m3n2 + 3mn4+ a b + 2ab + b2 23 + 3x − 6 x + 9x − 3 3 2 − 5m n4+ 3m n 2 3− n5 a 3 + 3a 2b + 3ab 2 + b 32x 4 − x 3+ 7x − 3 15m5 − 5m4n − 9m3n2 + 3m2n3 + 3mn4 − n5 12. a + a + 124. x − 3x + 19. 3y − 6y + 5323 x+3y2 + 2 a2 − a − 1 x 4 − 3x 3 +x3y 5 − 6y 3 + 5y 2a 4 + a3 + a2+ 3x − 9x 3 2+3 + 6y3− 12y + 10 − a3 − a2 − a x4 − 9x 2 + x + 33y 5 + 5y 2 − 12y + 10 − a2 − a − 1a4 − a 2 − 2a − 1
• 43. 13. x 3 + 2x 2 − x19. x 2 − 2xy + y 2 x 2 − 2x + 5− x 2 + xy + 3y 2 x + 2x − x 54 3 − x 4 + 2x 3 y − x 2 y 2 − 2x − 4 x + 2x4 3 2+ x 3 y − 2x 2 y 2 + xy 3+ 5x + 10x − 5 x 32+ 3x 2 y 2 − 6xy 3 + 3y 4 x5+ 12x 2 − 5x− x 4 + 3x 3 y− 5xy 3 + 3y 420. n − 2n + 1 214. m − 3m n + 2mn 322 m − 2mn − 8n 2 2 n2 − 1 m5 − 3m4n + 2m3n2 n4 − 2n3 + n2 − 2m4n + 6m3n 2 − 4m2n 3 − n2 + 2n − 1 − 8m3n 2 + 24m2n 3 − 16mn 4 n4 − 2n3+ 2n − 1 m − 5m n 54 + 20m n − 16mn 2 3415. x 2 + x + 1 21. a − 3a b + 4ab 322 x2 − x − 1a 2b − 2ab 2 − 10b 3 a 5b − 3a 4b 2 + 4a 3b 3 x4 + x3 + x2− 2a 4b 2 + 6a 3b 3 − 8a 2b 4 − x3 − x2 − x − 10a 3b 3 + 30a 2b 4 − 40ab 5− x2 − x −1 a 5b − 5a 4b 2+ 22a 2b 4 − 40ab 5 x4 − x 2 − 2x − 116. x − 3x + 2 4222. 8x 3 − 12x 2 y + 6xy 2 − 9y 3 x 2 − 2x + 32x + 3y x 6− 3x 4+ 2x 216x 4 − 24 x 3 y + 12x 2 y 2 − 18xy 3 − 2x 5+ 6x 3 − 4x + 24x 3 y − 36x 2 y 2 + 18xy 3 − 27y 4+ 3x 4 − 9x 2 +6 16x 4− 24 x 2 y 2− 27y 4 x 6 − 2x 5+ 6x 3 − 7 x 2 − 4 x + 623. 2y − 3y + y − 43217. m3 + m2 − 4m − 1 2y + 5 m3 + 1 4 y 4 − 6y 3 + 2y 2 − 8y m6 + m5 − 4m4 − m3+ 10y 3 − 15y 2 + 5y − 20+ m3 + m2 − 4m − 1 4y + 4y 3 − 13y 2 − 3y − 204 m6 + m5 − 4m4+ m2 − 4m − 124. − a + 2ax + 3x 3 2 318. a − 5a + 2 3 a −a+5 2 2a 2 − 3ax − x 2 a5 − 5a 3 + 2a 2− 2a 5+ 4a 3 x 2 + 6a 2 x 3 −a 4 + 5a − 2a2 + 3a x 4− 6a 2 x 3 − 9ax 4+ 5a3− 25a + 10 +a x3 2 − 2ax 4 − 3x 5 a5 − a4+ 7a 2 − 27a + 10− 2a + 3a x + 5a x5 43 2− 11ax 4 − 3x 5
• 44. 30. y − 2y + 1225. x 4 − 3x 3 y + 2x 2 y 2 + xy 3− x 2 − xy − y 2y 4 − 2y 2 + 2− x 6 + 3x 5 y − 2x 4 y 2 − x 2 y 3y 6 − 2y 5 + y 4− x 5 y + 3x 4 y 2 − 2x 3 y 3 − x 2 y 4 − 2y 4 + 4y 3 − 2y 2− x 4 y 2 + 3x 3 y 3 − 2x 2 y 4 − xy 5 + 2y 2 − 4y + 2− x 6 + 2x 5 y − 3x 2 y 4 − xy 5 y 6 − 2y 5 − y 4 + 4y 3 − 4y + 231. m − 3m + 4 4226. a 3 − 5a 2 + 2a − 3 a − 2a − 7 3 3m3 − 2m + 1 a 6 − 5a 5 + 2a 4 − 3a 33m7 − 9m5 + 12m3− 2a 4 + 10a 3 − 4a 2 + 6a − 2m 5 + 6m3− 8m− 7a + 35a − 14a + 21 3 2+m 4 − 3m 2 +4 a − 5a 65 + 31a − 8a + 21 2 3m − 11m + m + 18m − 3m − 8m + 4 754 3227. m + m − m + 3 32. a + a − a + 1 4 3 2 32 m − 2m + 32a + a 2 − 2a − 1 3 m6 + m5 − m4 + 3m2a6 + a 5 − a 4 + a3− 2m5 − 2m4 + 2m3 − 6m+a + a5 4− a3 + a2 + 3m4 + 3m3 − 3m2 +9 − 2a 4 − 2a 3 + 2a 2 − 2a m6 − m5+ 5m3− 6m + 9 − a 3 − a2 + a − 1 a 6 + 2a 5 − 2a 4 − 3a 3 + 2a 2 − a − 128. a 4 + a 3b − 3a 2b 2 − ab3 + b 433. 8x − 12x y − 6xy + y3 2 23 a 2 − 2ab + b2 3x 2 − 2xy + 4y 2 a 6 + a 5b − 3a 4b 2 − a 3b 3 + a 2b 4 24x 5 − 36x 4 y − 18x 3y 2 + 3x 2 y 3 − 2a b − 2a b + 6a b + 2a b − 2ab54 2 3 32 4 5 − 16x 4 y + 24x 3 y 2 + 12x 2 y 3 − 2xy 4 + a b + a b − 3a b − ab + b4 2 3 3 2 4 5 6+ 32x 3 y 2 − 48x 2 y 3 − 24xy 4 + 4y 5 a 6 − a 5b − 4a 4b 2 + 6a 3b 3 − 3ab5 + b6 24x 5 − 52x 4 y + 38x 3 y 2 − 33x 2 y 3 − 26xy 4 + 4y 529. x 4 − x 3 y + x 2 y 2 − xy 3 + y 434. 5a − 4a + 2a − 3a − 1432x 2 + xy − 2y 2a 4 − 2a 2 + 2x −x y+ x y 65 4 2− x y3 3 + x y2 4 5a 8 − 4a7 + 2a 6 − 3a 5 − a 4 + x 5 y − x 4 y 2 + x 3 y 3 − x 2 y 4 + xy 5 − 10a 6 + 8a 5 − 4a 4 + 6a 3 + 2a 2− 2x y + 2x y4 23 3 − 2x y + 2xy − 2y2 4 5 6 + 10a 4 − 8a 3 + 4a 2 − 6a − 2x6− 2x 4 y 2 + 2x 3 y 3 − 2x 2 y 4 + 3xy 5 − 2y 65a 8 − 4a7 − 8a 6 + 5a 5 + 5a 4 − 2a 3 + 6a 2 − 6a − 2
• 45. 35. x − x + x − x + 1 4 3 2 40. 3a 5 − 6a 3 + 2a 2 − 3a + 2x − 2x + 3x + 6 32 a 4 − 3a 2 + 4a − 5x7 − x 6 + x 5 − x 4 + x 33a 9 − 6a 7 + 2a 6 − 3a 5 + 2a 4 − 9a 7+ 18a 5 − 6a 4 + 9a 3 − 6a 2 − 2x 6 + 2x 5 − 2x 4 + 2x 3 − 2x 2+ 12a6− 24a 4 + 8a 3 − 12a 2 + 8a+ 3x 5 − 3x 4 + 3x 3 − 3x 2 + 3x − 15a 5 + 30a 3 − 10a 2 + 15a − 10+ 6x 4 − 6x 3 + 6 x 2 − 6x + 63a 9 − 15a 7 + 14a 6 − 28a 4 + 47a 3 − 28a 2 + 23a − 10x 7 − 3x 6 + 6x 5+ x 2 − 3x + 636. 3a + 2a − 5a − 4 41. a + b − c32a + a − 2a + 1 32a−b+c3a 6 + 2a 5 − 5a 4 − 4a 3 a 2 + ab − ac+ 3a 5 + 2a 4 − 5a 3 − 4a 2 − ab − b 2 + bc − 6a 4 − 4a 3 + 10a 2 + 8a+ ac+ bc − c 2+ 3a 3 + 2a 2 − 5a − 4 a2 − b 2 + 2bc − c 23a 6 + 5a 5 − 9a 4 − 10a 3 + 8a 2 + 3a − 437. 5y 4 − 3y 3 + 4y 2 + 2y42. x + 2y − zy 4 − 3y 2 − 1 x−y+z5y 8 − 3y 7 + 4 y 6 + 2y 5 x 2 + 2xy − xz− 15y 6 + 9y 5 − 12y 4 − 6y 3 − xy− 2y 2 + yz − 5y 4 + 3y 3 − 4y 2 − 2y + xz + 2yz − z 25y 8 − 3y 7 − 11y 6 + 11y 5 − 17y 4 − 3y 3 − 4y 2 − 2y x 2 + xy − 2y 2 + 3yz − z238. m − 2m n + 3m n − 4n 43. 2x − 3y + 5z 432 2 4 − m3 + 3m2n − 5mn2 + n3 − x + y + 2z − m7 + 2m6n − 3m5n2 + 4m3n4 − 2x 2 + 3xy − 5xz + 3m n − 6m n + 9m n6 5 24 3 − 12m2n5+ 2xy − 3y 2 + 5yz− 5m5n2 + 10m4n3 − 15m3n4+ 20mn6+ m4n3 − 2m3n4 + 3m2n5 − 4n7+ 4 xz − 6yz + 10z 2 − m7 + 5m6n − 14m5n2 + 20m4n3 − 13m3n4 − 9m2n5 + 20mn6 − 4n7− 2x 2 + 5xy − xz − 3y 2 − yz + 10z 239. x 6 − 3x 4 y 2 − x 2 y 4 + y 6 44. x 2 − xy − xz + y 2 − yz + z2x − 2x y + 3xy 53 2 4x +y+zx11 − 3x 9 y 2 − x 7 y 4 + x 5 y 6 x 3 − x 2 y − x 2z + xy 2 − xyz + xz 2 − 2x 9 y 2 + 6x 7 y 4 + 2x 5 y 6 − 2x 3 y 8+ x2y− xy 2 − xyz + y 3 − y 2 z + yz 2 + 3x 7 y 4 − 9x 5 y 6 − 3x 3 y 8 + 3xy10 +x z 2 − xyz − xz 2 + y 2z − yz 2 + z 3x11 − 5x 9 y 2 + 8x 7 y 4 − 6x 5 y 6 − 5x 3 y 8 + 3xy10x3− 3xyz + y3 + z3
• 46. x −1x−2EJERCICIO 43 7. a + 3a − 2a x x−2 ax − ax −1 + ax+ 2 x +11. a − a + ax a 2x + 3a 2 x − 1 − 2a 2x − 2 a +1− a 2 x − 1 − 3a 2 x − 2 + 2a 2 x − 3a x+ 3 −a x +2+a x +1+ a 2 x − 2 + 3a 2 x − 3 − 2a 2 x − 4 + a x + 2 − a x +1 + a xa 2x + 2a 2 x − 1 − 4a 2 x − 2 + 5a 2 x − 3 − 2a 2 x − 4x+ 3a +a xa+4 8. m − ma + 3 − 2ma + 2 + ma + 12. − xn + 3 + 2xn + 2 + xn + 1 a−3 − ma − 1 + ma − 2 + mx +x2 − m2a + 3 + m2a + 2 + 2m2a + 1 − m2a− x n + 5 + 2x n + 4 + x n + 3+ m2a + 2 − m2a + 1 − 2m2a + m2a − 1− x n + 4 + 2x n + 3 + x n + 2 + m2a + 1 − m2a − 2m2a − 1 + m2a − 2− x n + 5 + x n + 4 + 3 x n + 3 + xn + 2 2a + 32a + 2 −m + 2m+ 2m2a + 1 − 4m2a − m2a − 1 + m2a − 2a+ 2 a +1a −13. m + m − m + ma m2 − 2m + 3 9. x a − 1 + 2x a − 2 − x a − 3 + x a − 4 a−3 ma + 4 + ma + 3 − ma + 2 + ma + 1 xa − 1 − xa − 2 − x − 2ma + 3 − 2ma + 2 + 2ma + 1 − 2ma x 2a − 2 + 2x 2a − 3 − x 2a − 4 + x 2a − 5a+ 2a +1a −1+ 3m + 3m− 3m + 3ma− x 2a − 3 − 2 x 2a − 4 + x 2 a − 5 − x 2 a − 6 ma + 4 − ma + 3+ 6ma + 1 − 5ma + 3ma − 1− x 2 a − 4 − 2 x 2 a − 5 + x 2 a − 6 − x 2a − 7 x 2a − 2 + x 2a − 3 − 4 x 2a − 4 − x 2a − 7n+ 2 n +14. a + 3a − 2ann +1 a +an n −1 2n− 2 3 n−3 4 10. a b − a b + 2a b − a bn2n + 32n + 22n + 1a+ 3a− 2aanb2 − an − 2b4 + a 2n + 2 + 3a 2n +1 − 2a 2n a 2nb3 − a 2n − 1b 4 + 2a 2n − 2b 5 − a 2n − 3b6a 2n + 3 + 4a 2n + 2 + a 2n + 1 − 2a 2n − a 2n − 2b 5 + a 2n − 3b 6 − 2a 2n − 4b7 + a 2n − 5b 8 a 2nb3 − a 2n − 1b 4 + a 2n − 2b5 − 2a 2n − 4b7 + a 2n − 5b85. x a + 2 + 2x a +1 − x ax a + 3 − 2x a + 1 11. a x + b xx 2 a + 5 + 2x 2 a + 4 − x 2 a + 3 a m + bm2a + 3 2a + 22a + 1 − 2x − 4x+ 2x am + x + amb x2a + 5x+ 2x 2 a + 4 − 3x 2a + 3 − 4 x 2 a + 2 + 2x 2 a + 1+ a xbm + bm + x m+ x a + a b + a xbm + bm + xm x x −1x−26. a − 2ax+ 3aa 2 + 2a − 1x −1 n−1 12. a − bx+2 x +1a− 2a+ 3a x a−bx +1 + 2a− 4a x + 6a x − 1 a x − abn − 1 x −1 x−2− a + 2ax− 3a− a x − 1b + bnx+2x −1x−2a− 2a + 8ax− 3a a − ab x n −1− a x − 1b + bn
• 47. 13. − 5a m + + a m + + 3a m2 2 2 126a 3m − 1 − 8a 3m − 2 + a 3m − 3 − 30a 5m + 1 + 6a 5m + 18a 5m − 1 + 40a 5m − 8a 5m − 1 − 24a 5m − 2− 5a 5m − 1 + a 5m − 2+ 3a 5m − 3 − 30a 5m + 1 + 46a 5m + 5a 5m − 1 − 23a 5m − 2 + 3a 5m − 3 a + 2 x −1 a +1 x a x +114. x y − 4x y + 3x y− 2x 2a − 1y x − 2 − 4x 2a − 2 y x − 1 − 10x 2a − 3 y x− 2x 3a + 1y 2 x − 3 + 8x 3a y 2 x − 2 − 6x 3a − 1y 2x − 1 − 4x 3a y 2 x − 2 + 16x 3a − 1y 2 x − 1 − 12x 3a − 2 y 2x − 10x 3a − 1y 2 x − 1 + 40x 3a − 2 y 2 x − 30x 3a − 3 y 2 x + 1− 2x 3a + 1y 2 x − 3 + 4x 3a y 2 x − 2+ 28x 3a − 2 y 2 x − 30x 3a − 3 y 2x + 1EJERCICIO 441 2 1 1 3. x − xy + y 22 3 4 1 11. a− b 23 2 3x− y32 1 1 a+ b 2 32 2 2 3 2x −x y+ xy 26912 1 2 1 a − ab3 2 3 2 3 6 9 − x y+xy − y 3 4 6 8 1 1 + ab − b22 3 8 + 27 22+6 2 3 3 4 6x − x y+xy − y6 36 128 1 2 4−9 1 a − ab − b 2 1 3 35 2 83 3 6 366= x −x y+xy − y23 36128 1 5 1 = a2 +ab − b21 3 35 22 2 3 3 636 6= x −x y + xy − y3 363822. x −y 1 2 254. a − ab + b24 3 15 x+ y 13 36 a− b42 1 22 x − xy1 31 2 2 3 15a −ab + ab216412510 2 +xy −y 3 23 2 6 3630 − ab +ab − b82 6 1 2 4 − 25 10 2 x − xy −y 1 3 2+3 22 + 18 2 33030 a −a b+ab − b316812 1211 = x2 +xy − y 21 3 5 220 2 3303 =a − a b+ ab − b3168 12 1 71 = x2 +xy − y 21 3 5 25 3103 =a − a b + ab 2 − b168 3
• 48. 2 2 1 13 2 125. m + mn − n2 6. x + x− 5 3 284 5 3 2 1 m − mn + 2n2 2x − x + 23 236 4 3 3 3 2 2 6 5 2 4 4 3m + m n − m n x + x − x 1064 84 5 211 3 3 1 22− m3n − m2n2 + mn 3− x− x + x 5322412 15 422 46 22 4 + m2n2 + mn 3 − n+x+ x− 53284 56 4 15 − 12 3 45 + 20 − 48 2 2 3 + 42 6 5 2 4 96 + 15 3 2 − 18 2 8 + 30 4m + m n−m n +mn3 − n4 x + x −x − x + x− 10 30 6062 8412024 6056 43 3 17 2 2 7 3 5 1 4 111 3 16 2 38 4 =m +m n −m n + mn 3 − n 4= x + x − x +x + x− 10 30 60642120 24605 3 4 1 3 17 2 2 7 3 5 1 4 37 3 2 2 19 4 = m + m n −m n + mn3 − n4= x + x −x + x + x− 510 6064240 33052 3 1 1 2 11 3 x − x2y + xy7. − 2 x + 3 ax + 2 a 8.2 27 5 21 2 2 5 2x −xy + y 3 2 2436 x − ax + a 2 2 3 2 51 41 3 2 x −x y+x y 3 4 3 39 2 2 28 208 − x + ax + a x 4 42 3 22 2 3 46 4−x y+ x y− x y 21 1561 1 2 23 + ax 3 − a x − a3x10 3 25 2 352 32+ x y −x y +xy 4 42 30 122 2 22 6 4− a x + a3x+ a2 5 x − 21+ 80 4x y+ 105 + 112 + 200 3 2 10 + 5 2 3 5 x y − x y +xy 469 6 28 420840 3012 3 4 3 + 3 3 27 − 4 − 4 2 2 27 − 4 3 6=2 5x −101 4 x y+417 3 2 15 2 3x y −x y +5xy 4 − x +ax + a x −a x + a4 28 420 840 30 12 46121861 5 101 4 139 3 2 1 2 3 5 36 19 2 2 23 3 6 = x −x y+ x y − x y +xy 4 = − x 4 + ax 3 +a x − a x + a414 420 280212 46 12186 3 419 2 2 23 3 = − x + ax +3 a x − a x+a4 41218 1 3 1 2 119. x + x − x+ 4 3 42 3 21 1 x +x− 2 10 5 3 5 3 43 3 3 2 x + x− x +x 8 68 41 41 3 1 21 +x + x − x+x 40 3040 20 1 31 2 11− x −x +x −20 1520 103 5 60 + 3 4 45 − 4 + 6 3 90 − 3 − 8 2 1+ 11x +x −x + x +x−8 120 12012020103 63 4 47 3 79 2 21 3 5 21 4 47 3 79 2 11 = x5 +x − x + x +x−= x +x − x + x +x−8120 120 120 2010 840120 120 1010
• 49. 3 1 2 110. 4 m − 2 m n + 5 mn − 4 n 3 2232 2 2 5m − mn + n2332 6 5 2 4 4 3 2 2 2 3 m − m n +m n −m n12 615126 42 3 2 4 2 3 2 −m n+m n − m n +mn 4 1261512 15 3 2 5 2 3 105 5+m n− m n +mn 4 − n8 4 108 6 5 4+6 432 + 40 + 225 3 2 10 + 16 + 75 2 3 20 + 1205 m − m n+ m n − m n + mn4 − n512 121206012081 5 10 4 297 3 2 101 2 3 1405 5 1 5 5 499 3 2 101 2 3 75 = m −m n+ m n − m n + mn − n = m − m n + 4m n −m n + mn 4 − n521212060 1208 2 640 6068EJERCICIO 454. m − 5m n + 6mn + n por m − 4mn − n 3 2 2 3 3 2 31. x − x + x por x − 13 2 2 1− 1+ 1 1− 5 + 6 + 1 1+ 0 − 11 + 0 − 4 −11− 1+ 11− 5 + 6 + 1− 1+ 1− 1− 4 + 20 − 24 − 4 −1 + 5 − 6 −11− 1+ 0 + 1− 1 = x5 − x 4 + x 2 − x1− 5 + 2 + 20 − 19 − 10 − 1 = m6 − 5m5n + 2m4n2 + 20m3n3 − 19m2n4 − 10mn5 − n62. x + 3 x − 5x + 8 por x − 2x − 7432325. x − 8x + 3 por x + 6x − 5424 2 1+ 3 − 5 + 0 + 81+ 0 − 8 + 0 + 3 1− 2 + 0 − 71+ 0 + 6 + 0 − 51+ 3 − 5 + 0 + 8 1+ 0 − 8 + 0 + 3 − 2 − 6 + 10 + 0 − 16 + 6 + 0 − 48 + 0 + 18 − 7 − 21+ 35 + 0 − 56− 5 + 0 + 40 + 0 − 151+ 1− 11+ 3 − 13 + 19 + 0 − 56 1+ 0 − 2 + 0 − 50 + 0 + 58 + 0 − 15 = x 7 + x 6 − 11x 5 + 3x 4 − 13x 3 + 19x 2 − 56 = x 8 − 2x 6 − 50x 4 + 58x 2 − 156. a 6 − 3a 4 − 6a 2 + 10 por a 8 − 4a 6 + 3a 4 − 2a 23. a + 3a b − 2a b + 5ab − b4 3 2 2 3 4por a − 2ab + b2 21+ 0 − 3 + 0 − 6 + 0 + 10 1+ 3 − 2 + 5 − 11+ 0 − 4 + 0 + 3 + 0 − 2 1− 2 + 11+ 0 − 3 + 0 − 6 + 0 + 101+ 3 − 2 + 5 − 1 − 4 + 0 + 12 + 0 + 24 + 0 − 40 − 2 − 6 + 4 − 10 + 2 + 3 + 0 − 9 + 0 − 18 + 0 + 30+1 + 3 − 2 + 5 −1 − 2 + 0 + 6 + 0 + 12 + 0 − 201+ 1− 7 + 12 − 13 + 7 − 11+ 0 − 7 + 0 + 9 + 0 + 23 + 0 − 52 + 0 + 42 + 0 − 20 = a + a b − 7a b + 12a b − 13a b + 7ab − b6 5 4 2 3 3 2 45 6 = a14 − 7a12 + 9a10 + 23a 8 − 52a 6 + 42a 4 − 20a 2
• 50. 8. m − 7m + 9m − 15 por m − 5m + 9m − 4m + 312 8416 12 847. x 9 − 4x 6 + 3x 3 − 2 por 3x 6 − 8x 3 + 10 1− 7 + 9 − 15 1+ 0 + 0 − 4 + 0 + 0 + 3 + 0 + 0 − 2 1− 5 + 9 − 4 + 3 3 + 0 + 0 − 8 + 0 + 0 + 10 1− 7 + 9− 153 + 0 + 0 − 12 + 0 + 0 + 9 + 0 + 0 − 6 − 5 + 35 − 45 + 75 − 8 + 0 + 0 + 32 + 0 + 0 − 24 + 0 + 0 + 16 + 9 − 63 + 81 − 135+ 10 + 0 + 0 − 40 + 0 + 0 + 30 + 0 + 0 − 20 − 4 + 28 − 36 + 603 + 0 + 0 − 20 + 0 + 0 + 51+ 0 + 0 − 70 + 0 + 0 + 46 + 0 + 0 − 20+ 3 − 21 + 27 − 45= 3x15 − 20x12 + 51x 9 − 70x 6 + 46x 3 − 201− 12 + 53 − 127 + 187 − 192 + 87 − 45= m28 − 12m24 + 53m20 − 127m16 + 187m12 − 192m8 + 87m4 − 4510. 6a − 4a + 6a − 2 por a − 2a + a − 752429. x 5 − 3x 4 y − 6x 3 y 2 − 4x 2 y 3 − y 5 por 2x 2 + 4y 26+0+0−4+6−21− 3 − 6 − 4 + 0 − 1 1+ 0 − 2 + 1− 72+0+46+0+ 0 −4+ 6 −22 − 6 − 12 − 8 + 0 − 2− 12 + 0 + 0 + 8 − 12 + 4+ 4 − 12 − 24 − 16 + 0 − 4 + 6+ 0 +0−4 +6 − 22 − 6 − 8 − 20 − 24 − 18 + 0 − 4− 42 + 0 + 0 + 28 − 42 + 14= 2x 7 − 6x 6 y − 8x 5 y 2 − 20 x 4 y 3 − 24 x 3 y 4 − 18x 2 y 5 − 4y 76 + 0 − 12 + 2 − 36 + 6 − 16 + 38 − 44 + 14 = 6a 9 − 12a 7 + 2a 6 − 36a 5 + 6a 4 − 16a 3 + 38a 2 − 44a + 1412. 3x 4 − 4x 3 y − y 4 por x 3 − 5xy 2 + 3y 311. n − 3n + 5n − 8n + 4 por n − 3n + 46 4 34 23 − 4 + 0 + 0 −11+ 0 − 3 + 5 + 0 − 8 + 41+ 0 − 5 + 31+ 0 − 3 + 0 + 43 − 4 + 0 + 0 −11+ 0 − 3 + 5 + 0 − 8 + 4− 15 + 20 + 0 + 0 + 5− 3 + 0 + 9 − 15 + 0 + 24 − 12+ 9 − 12 + 0 + 0 − 3 + 4 + 0 − 12 + 20 + 0 − 32 + 163 − 4 − 15 + 29 − 13 + 0 + 5 − 31+ 0 − 6 + 5 + 13 − 23 − 8 + 44 − 12 − 32 + 16= 3x 7 − 4 x 6 y − 15x 5 y 2 + 29x 4 y 3 − 13x 3 y 4 + 5 xy 6 − 3y 7 = n10 − 6n8 + 5n7 + 13n6 − 23n5 − 8n 4 + 44n3 − 12n2 − 32n + 1613. x10 − 5x 6 y 4 + 3x 2 y 8 − 6y10 por x 6 − 4x 4 y 2 − 5x 2 y 4 + y 61+ 0 + 0 + 0 − 5 + 0 + 0 + 0 + 3 + 0 − 61+ 0 − 4 + 0 − 5 + 0 + 11+ 0 + 0 + 0 − 5 + 0 + 0 + 0 + 3 + 0 − 6− 4 + 0 + 0 + 0 + 20 + 0 + 0 + 0 − 12 + 0 + 24− 5 + 0 + 0 + 0 + 25 + 0 + 0 + 0 − 15 + 0 + 30 + 1 + 0+ 0 + 0− 5 +0+ 0+0+ 3 +0 −61+ 0 − 4 + 0 − 10 + 0 + 21+ 0 + 28 + 0 − 23 + 0 + 9 + 0 + 33 + 0 − 6x16 − 4 x14 y 2 − 10x12 y 4 + 21x10 y 6 + 28x 8 y 8 − 23x 6 y10 + 9x 4 y12 + 33x 2 y14 − 6y1615. a − 5a − 7apor 7a x + 3 + 6a x + 1 + a x x+2x +1x −1m−1 m− 314. a − 3a + 5apor a 2 − 5 m1− 3 + 0 + 5 1− 5 + 0 − 71+ 0 − 5 7 + 0 + 6 +11− 3 + 0 + 5 7 − 35 + 0 − 49 − 5 + 15 + 0 − 25 + 6 − 30 + 0 − 42+ 1 −5+ 0 −71− 3 − 5 + 20 + 0 − 25 7 − 35 + 6 − 78 − 5 − 42 − 7 = a m + 2 − 3a m + 1 − 5a m + 20a m − 1 − 25a m − 3 = 7a 2 x + 5 − 35a 2 x + 4 + 6a 2 x + 3 − 78a 2 x + 2 − 5a 2 x + 1 − 42a 2 x − 7a 2 x −1
• 51. 16. x − 5x a − 6 x a − 2 por 6x a + 1 − 4 x a + 2x a − 1 + x a − 2a+217. a2x + 2 − 3a 2 x + 1 − a 2 x − 5a 2 x − 1 por 6a 3x + 1 − 5a 3x + 3a 3x − 1 1+ 0 − 5 + 0 − 61− 3 − 1− 5 6 − 4 + 2 +16−5+36 + 0 − 30 + 0 − 366 − 18 − 6 − 30− 4 + 0 + 20 + 0 + 24− 5 + 15 + 5 + 25 + 2 + 0 − 10 + 0 − 12 + 3 − 9 − 3 − 15+ 1+ 0 − 5 + 0 − 6 6 − 23 + 12 − 34 + 22 − 156 − 4 − 28 + 21− 46 + 19 − 12 − 6= 6a 5x + 3 − 23a 5 x + 2 + 12a 5 x +1 − 34a 5 x + 22a 5 x − 1 − 15a 5 x − 2= 6x 2a + 3 − 4 x 2a + 2 − 28x 2a + 1 + 21x 2a− 46x 2a − 1 + 19x 2a − 2 − 12x 2a − 3 − 6x 2a − 4EJERCICIO 46 ()( 4. x + 1 x − 1 x + 1 2 2 2)( )( )( 6. a − b a − 2ab + b a + b 2 2)() (1. 4 a + 5 a − 3 )( )x +12a 2 − 2ab + b 2 4a + 20 x2 + 1 a+ba−3 x4 + x2a 3 − 2a 2b + ab2 4a 2 + 20a + x2 + 1+ a 2b − 2ab2 + b3− 12a − 60 x 4 + 2 x2 + 1 a 3 − a 2b − ab 2 + b 3 4a 2 + 8a − 60a−b x2 − 1a 4 − a 3b − a 2b 2 + ab 3 x 6 + 2 x 4 + x2 (2. 3a x + 1 x − 1 2)()− x4 − 2 x 2 − 1− a 3b + a 2b 2 + ab3 − b 4 3a 2 x + 3a 2a 4 − 2a 3b+ 2ab3 − b 4 x6 + x4 − x2 − 1 x−1 3a 2 x 2 + 3a 2 x − 3a 2 x − 3a 2 3a 2 x 2− 3a 2( )( 5. m m − 4 m − 6 3m + 2 )( ) ( )( 7. 3x x 2 − 2 x + 1 x − 1 x + 1 )( ) m − 4m 23x − 6 x + 3x32 m− 6x−1 ( )(3. 2 a − 3 a − 1 a + 4 )( )m 3 − 4 m23x 4 − 6 x 3 + 3x 2 2a − 6 − 6m2 + 24m − 3 x 3 + 6 x 2 − 3x a −1 m − 10m + 24m 323x 4 − 9 x 3 + 9 x 2 − 3x 2a 2 − 6a 3m + 2− 2a + 6x+1 3m4 − 30m3 + 72m2 2a 2 − 8a + 63x 5 − 9 x 4 + 9 x 3 − 3x 2 + 2m3 − 20m2 + 48m a+4+ 3x 4 − 9 x 3 + 9 x 2 − 3x 3m4 − 28m3 + 52m2 + 48m 2a 3 − 8a 2 + 6a 3x 5 − 6 x 4 + 6 x 2 − 3x + 8a − 32a + 242 2a3− 26a + 24
• 52. 11. (x − 3)(x + 4)( x − 5)( x + 1)()(8. x − x + 1 x + x − 1 x − 22 2)( ) x−3 x−5x2 − x + 1 x+ 4x+1x2 + x − 1 x 2 − 3x x 2 − 5x + 4 x − 12 + x −5x4 − x3 + x2 x 2 + x − 12 x2 − 4 x − 5+ x3 − x2 + x x2 − 4x − 5 − x2 + x − 1 x 4 + x 3 − 12 x 2x4 − x2 + 2x − 1 − 4 x 3 − 4 x 2 + 48xx− 2 − 5x 2 − 5x + 60x 5 − x + 2x − x32 x 4 − 3x 3 − 21x 2 + 43x + 60− 2x 4+ 2x − 4x + 2212. (x − 3)( x + 2 x + 1)( x − 1)(x + 3) 222x − 2 x − x + 4 x 2 − 5x + 2543x + 2x + 1 2 x2 − 3 x2 + 3x−1 x + 2x + x 4 3 2 x 3− 3x9. (a − 3)(a + 2)(a − 1)m m −1 m −1 + 3x 2 + 6 x + 3− x2+3 a −3 m x 4 + 2 x3 + 4 x2 + 6x + 3 x 3 − x 2 − 3x + 3 a m −1 + 2x 3 − x 2 − 3x + 3 2 m −1m −1+a− 3a x 7 + 2 x 6 + 4 x 5 + 6 x 4 + 3x 3 2a m−6 − x 6 − 2 x 5 − 4 x 4 − 6 x 3 − 3x 2 2 m −1m −12a + am− 3a−6 − 3x 5 − 6 x 4 − 12 x 3 − 18 x 2 − 9 x a m −1 − 1+ 3x 4 + 6 x 3 + 12 x 2 + 18 x + 92 m −13m − 22m−2m −12a +a− 3a− 6ax +x −x 7 6 5 − x 4 − 9 x 3 − 9 x2 + 9 x + 92 m −1m −1 − a + 3a− 2a + 6 m13. 9a (3a − 2)(2a + 1)(a − 1)(2a − 1)22 m −13m − 22m−2m −1a+a− 3a− 3a− 2a m + 627a 3 − 18a 2 2a − 1⇒ a 3m − 2 + a 2 m −1 − 3a 2 m − 2 − 2a m − 3a m −1 + 62a + 1a−1 54a 4 − 36a 32a 2 − a + 27a − 18a 32 − 2a + 1(10. a a − 1 a − 2 a − 3)()( )54a − 9a − 18a 4 32 2a − 3a + 1 2a2 − a 2a 2 − 3a + 1a−2 108a 6 − 18a 5 − 36a 4a3 − a2− 162a 5 + 27a 4 + 54a 3− 2a + 2a2 + 54a 4 − 9a 3 − 18a 2a − 3a + 2a32 108a − 180a + 45a 4 − 45a 3 − 18a 2 6 5a−3a 4 − 3a 3 + 2a 2 x +114. a a + b x (x +2)(a x +1 − b x + 2 )b x 2 x +1x+2 a +a bx − 3a 3 + 9a 2 − 6a x +1 x a b − b2 x + 2a 4 − 6a 3 + 11a 2 − 6a a 3 x + 2b x + a 2 x + 1b 2 x + 2 − a 2 x + 1b2 x + 2 − a xb 3x + 4 a 3 x + 2b x− a xb 3 x + 4
• 53. EJERCICIO 47() 2 (11. 3 x + y − 4 x − y + 3x 2 − 3 y 2 ) 21. 4 ( x + 3) + 5( x + 2 ) = 3( x + y )( x + y ) − 4 ( x − y )( x − y ) + 3x 2 − 3 y 2= 4 x + 12 + 5x + 10 = 3( x 2 + xy + xy + y 2 ) − 4( x 2 − xy − xy + y 2 ) + 3x 2 − 3 y 2= 9 x + 22 = 3( x 2 + 2 xy + y 2 ) − 4( x 2 − 2 xy + y 2 ) + 3x 2 − 3 y 2 () (2. 6 x + 4 − 3 x + 1 + 5 x + 22 2 2) ( )= 3x 2 + 6 xy + 3 y 2 − 4 x 2 + 8 xy − 4 y 2 + 3x 2 − 3 y 2 = 6x + 24 − 3x − 3 + 5x + 102 2 2 = 2 x 2 + 14 xy − 4 y 2 = 8x + 31212. (m + n) − (2m + n) + (m − 4n)22 23. a (a − x ) + 3a( x + 2a ) − a( x − 3a ) = a 2 − ax + 3ax + 6a 2 − ax + 3a 2= (m + n )(m + n ) − (2m + n)(2m + n) + (m − 4n)(m − 4n) = 10a + ax 2= m2 + 2mn + n 2 − (4m2 + 4mn + n 2 ) + m2 − 8mn + 16n 24. x ( y + 1) + y ( x + 1) − 3x y2 22 2 2 2= 2m2 − 6mn + 17n 2 − 4m2 − 4mn − n 2= − 2m2 − 10mn + 16n 2 = x 2 y 2 + x 2 + x 2 y 2 + y 2 − 3x 2 y 2 = − x2 y2 + x2 + y2() () ( )(13. x a + x + 3x a + 1 − x + 1 a + 2 x − a − x) ()25. 4m − 5mn + 3m (m + n ) − 3m(m − n ) + 3ax + 3x − (ax + 2 x + a + 2 x ) − (a − x)(a − x )3 2 2 2 2 2 2 = ax + x 22 = 4m3 − 5mn 2 + 3m4 + 3m2 n 2 − 3m3 + 3mn2 = 4ax + x + 3x − ax − 2 x 22− a − 2 x − (a − ax − ax + x )2 2= 3m4 + m3 + 3m2 n 2 − 2mn2 = 3ax − x 2 + x − a − a 2 + ax + ax − x 22 3 3 2 2 2(6. y + x y − y x + 1 + y x + 1 − y x − 12 2 2) ( ) ( )= − 2 x 2 + x + 5ax − a − a 2= y2 + x2 y3 − x2 y3 − y3 + x2 y2 + y2 − x2 y2 + y2= − y 3 + 3y 214. (a + b − c) + (a − b + c) − (a + b + c) 22 2( ) ( )( )7. 5 x + 2 − x + 1 x + 4 − 6 x a+b− ca−b+ c= 5x + 10 − ( x + 4 x + x + 4) − 6 x2a+ b− c a−b+ c a 2 + ab − ac a 2 − ab + ac= − x + 10 − x 2 − 4 x − x − 4+ ab + b 2 − bc − ab + b 2 − bc= − x 2 − 6x + 6 − ac− bc + c 2 + ac− bc + c 28. (a + 5)(a − 5) − 3(a + 2)(a − 2) + 5(a + 4) a + 2ab − 2ac + b − 2bc + c222 a − 2ab + 2ac + b 2 − 2bc + c 22= a 2 − 5a + 5a − 25 − 3(a 2 − 2a + 2a − 4) + 5a + 20 a+b+ c= a 2 + 5a − 5 − 3 (a 2 − 4) a+b+ c= a 2 + 5a − 5 − 3a 2 + 12 a 2 + ab + ac= − 2a 2 + 5a + 7 + ab + b 2 + bc9. (a + b)(4a − 3b) − (5a − 2b)(3a + b) − (a + b)(3a − 6b) + ac+ bc + c 2= 4a 2 + ab − 3b 2 − (15a 2 − ab − 2b 2 ) − (3a 2 − 3ab − 6b 2 ) a + 2ab + 2ac + b + 2bc + c 222= 4a 2 + ab − 3b 2 − 15a 2 + ab + 2b 2 − 3a 2 + 3ab + 6b 2a 2 + 2ab − 2ac + b 2 − 2bc + c 2= − 14a 2 + 5ab + 5b 2a 2 − 2ab + 2ac + b 2 − 2bc + c 2( ) ( )10. a + c − a − c2 2− a 2 − 2ab − 2ac − b 2 − 2bc − c 2= (a + c)(a + c) − (a − c)(a − c)a 2 − 2ab − 2ac + b 2 − 6bc + c 2= a + ac + ac + c − (a − ac − ac + c )2 2 2 2 ⇒ a 2 + b 2 + c 2 − 2ab − 2ac − 6bc= a 2 + 2ac + c 2 − a 2 + ac + ac − c 2= 4ac
• 54. ( ) ( 215. x + x − 3 − x − 2 + x + x − x − 3 2 2 2) (2)2( ) (2 16. x + y + z − x + y x − y + 3 x + xy + y2 2)( ) ( ) x + x− 3 2 x + x−22 x+ y+ z x+ yx+ y+ z x− y x + x− 3 2 x2 + x − 2x 2 + xy + xz x 2 + xy x 4 + x 3 − 3x 2 x4 + x3 − 2x2+ xy+ y 2 + yz − xy − y 2 + x 3 + x 2 − 3x + x3 + x2 − 2x − 3 x 2 − 3x + 9− 2x2 − 2x + 4 + xz + yz + z 2 x2 − y2 x 4 + 2 x 3 − 5x 2 − 6 x + 9 x 4 + 2 x 3 − 3x 2 − 4 x + 4x + 2 xy + 2 xz + y + 2 yz + z2 2 2 x2 − x − 3 x 2 + 2 xy + 2 xz + y 2 + 2 yz + z 2 x2 − x − 3 − x2+ y23x + 3xy2+ 3y 2 x 4 − x 3 − 3x 2 x 4 + 2 x 3 − 5x 2 − 6 x + 9 − x 3 + x 2 + 3x − x 4 − 2 x 3 + 3x 2 + 4 x − 43x 2 + 5xy + 2 xz + 5y 2 + 2 yz + z 2 − 3x 2 + 3x + 9x 4 − 2 x 3 − 5x 2 + 6 x + 9⇒ 3x 2 + 5y 2 + z 2 + 5xy + 2 xz + 2 yz x 4 − 2 x 3 − 5x 2 + 6 x + 9x 4 − 2 x 3 − 7 x 2 + 4 x + 14[18. 3 ( x + 2) − 4 ( x + 1) 3( x + 4) − 2 ( x + 2)][ ][ ][17. x + (2 x − 3) 3x − ( x + 1) + 4 x − x2] [][= 3x + 6 − 4 x − 4 3x + 12 − 2 x − 4 ] [][] = x + 2 x − 3 3x − x − 1 + 4 x − x 2 = [− x + 2][x + 8] = [3x − 3][2 x − 1] + 4 x − x2= − x 2 − 8 x + 2 x + 16 = 6 x 2 − 3x − 6 x + 3 + 4 x − x 2 = − x 2 − 6 x + 16 = 5x − 5x + 3220. [(x + y) − 3(x − y) ][(x + y)(x − y) + x (y − x)]2 2[()( )][ ( ) ( )] ) (19. m + n m − n − m + n m + n 2 m + n − 3 m − n)([ ][= x 2 + 2 xy + y 2 − 3 (x 2 − 2 xy + y 2 ) x 2 − y 2 + xy − x 2 ] = [m − n − (m + 2mn + n )][2m + 2n − 3m + 3n][ ][xy − y ] 2 2 22= x + 2 xy + y − 3x + 6xy − 3 y2 2 2 22 = [m − n − m − 2mn − n ][− m + 5n][ ][] 2 2 22= − 2 x 2 + 8xy − 2 y 2 xy − y 2 = [− 2mn − 2n ][− m + 5n] 2= − 2 x 3 y + 2 x 2 y 2 + 8 x 2 y 2 − 8xy 3 − 2 xy 3 + 2 y 4 = 2m2 n − 10mn2 + 2mn 2 − 10n 3= − 2 x 3 y + 10x 2 y 2 − 10xy 3 + 2 y 4 = 2m n − 8mn − 10n22 3EJERCICIO 48[ 3. − 3x − 2 y + ( x − 2 y) − 2 ( x + y) − 3(2 x + 1)][= − 3x − 2 y + x − 2 y − 2 x − 2 y − 6 x − 3 ] [1. x − 3a + 2 (− x + 1)][= − − 4x − 6y − 3 ] [ = x − 3a − 2 x + 2]= 4x + 6y + 3 = x − 3a + 2 x − 2 = 3 x − 3a − 2{ 4. 4 x 2 − − 3x + 5 − − x + x 2 − x[)] } (= 4x2 − {− 3x + 5 − [− x + 2 x − x ] }[ ]22. − (a + b) − 3 2a + b (− a + 2)[ = − a − b − 3 2a − ab + 2b ] = 4x2 − {− 3x + 5 + x − 2 x + x } 2 = − a − b − 6a + 3ab − 6b= 4x2 − {− 4 x + 5 + x }2 = − 7a − 7b + 3ab ⇒ − 7a + 3ab − 7b= 4x2 + 4x − 5− x2= 3x 2 + 4 x − 5
• 55. {[5. 2a − − 3x + 2 − a + 3x − 2 − a + b − 2 + a ()) ] }( [{(10. m − 3(m + n) + − − − 2m + n − 2 − 3[m − n + 1] + m) }] = m − 3m − 3n + [ − {− (− 2m + n − 2 − 3m + 3n − 3) + m}] = 2a − {− 3x + 2 [− a + 3x − 2 (− a + b − 2 − a )] } = − 2m − 3n + [ − {− (− 5m + 4n − 5) + m}] = 2a − {− 3x + 2 [− a + 3x + 2a − 2b + 4 + 2a ] } = − 2m − 3n + [− {5m − 4n + 5 + m}] = 2a − {− 3x + 2 [3a + 3x − 2b + 4 ] } = − 2m − 3n + [− {6m − 4n + 5}] = 2a − {− 3x + 6a + 6 x − 4b + 8} [ = − 2m − 3n + − 6m + 4n − 5] = 2a + 3x − 6a − 6 x + 4b − 8 = − 2m − 3n − 6m + 4n − 5 = − 4a − 3x + 4b − 8 ⇒ − 4a + 4b − 3x − 8 = − 8m + n − 5[6. a − ( x + y ) − 3( x − y) + 2 − ( x − 2 y) − 2 (− x − y) ][ = a − x − y − 3x + 3 y + 2 − x + 2 y + 2 x + 2 y] = a − 4x + 2y + 2 x + 4y [] { [11. − 3( x − 2 y ) + 2 − 4 − 2 x − 3( x + y) ] } − {− [− (x + y)] } = a − 4x + 2 y + 2x + 8y= − 3x + 6 y + 2 {− 4 [− 2 x − 3x − 3 y ] } − {− [− x − y] } = a − 2 x + 10 y= − 3x + 6 y + 2 {− 4[− 5x − 3 y] } − {x + y} = − 3x + 6 y + 2 {20 x + 12 y} − x − y{ [7. m − (m + n) − 3 − 2m + − 2m + n + 2 (− 1 + n) − (m + n − 1) ]} = − 4 x + 5 y + 40 x + 24 y{ [ = m − m − n − 3 − 2m + − 2m + n − 2 + 2n − m − n + 1]}= 36 x + 29 y {[ = − n − 3 − 2m + − 3m + 2n − 1 ]} = − n − 3 {− 2m − 3m + 2n − 1} = − n − 3 { − 5m + 2n − 1} = − n + 15m − 6n + 3{[12. 5 − (a + b) − 3 − 2a + 3b − (a + b) + (− a − b) + 2 (− a + b) − a] } = − 7n + 15m + 3 ⇒ 15m − 7n + 3{[] }= 5 − a − b − 3 − 2a + 3b − a − b − a − b − 2a + 2b − a{[] }= 5 − a − b − 3 − 6a + 3b − a{[8. − 2 (a − b) − 3(a + 2b) − 4 a − 2b + 2 − a + b − 1 + 2 (a − b)]} = 5 {− 2 a − b + 18a − 9b} = − 2a + 2b − 3a − 6b − 4 {a − 2b + 2 [− a + b − 1 + 2a − 2b] }= 5{16a − 10b} = − 5a − 4b − 4 {a − 2b + 2 [a − b − 1] }= 80a − 50b = − 5a − 4b − 4 {a − 2b + 2a − 2b − 2} = − 5a − 4b − 4 {3a − 4b − 2} = − 5a − 4b − 12a + 16b + 8{[13. − 3 − + (− a + b) ] } − 4 {− [− (− a − b)] }= − 3{− [− a + b] } − 4 {− [a + b] } = − 17a + 12b + 8= − 3{a − b} − 4 {− a − b}[ { }]9. − 5( x + y) − 2 x − y + 2 − x + y − 3 − ( x − y − 1) + 2 x= − 3a + 3b + 4a + 4b = − 5x − 5y − [2 x − y + 2{− x + y − 3 − x + y + 1}] + 2 x= a + 7b = − 3x − 5y − [2 x − y + 2 {− 2 x + 2 y − 2}] [ = − 3x − 5y − 2 x − y − 4 x + 4 y − 4 ] { {[]} [14. − a + b − 2 (a − b ) + 3 − 2a + b − 3 (a + b − 1) − 3 − a + 2 (− 1 + a ) ]} = − 3x − 5y − [− 2 x + 3 y − 4]= − {a + b − 2 a + 2b + 3 {− [2a + b − 3a − 3b + 3] } − 3[− a − 2 + 2a ] } = − 3x − 5y + 2 x − 3 y + 4 = − x − 8y + 4 = − {− a + 3b + 3 {a + 2b − 3} − 3a + 6}= − {− 4a + 3b + 6 + 3a + 6b − 9}= − {− a + 9b − 3}= a − 9b + 3
• 56. EJERCICIO 491 8 9 4 −4112. − a b c ÷ 8c = − = − a 8b9 8 9 44a b c8 81. − 24 ÷ 8 = − 3 16 6 4 − 3162. − 63 ÷ − 7 = 9 13. 16m n ÷ − 5n = − 6 43mn= − m6n5 53. − 5a 2 ÷ − a = 5a 2 − 1 = 5a 108 7 6 − 6 8 − 8 27 714. − 108a b c ÷ − 20b c ==7 6 8 6 8 ab c a4. 14a 3b 4 ÷ − 2ab 2 = − 7a 3 − 1b4 − 2 = − 7a 2b 22055. − a 3b 4 c ÷ a 3b 4 = − a 3 − 3b 4 − 4 c = − c 2 2 −1 6 − 6 215. − 2m n ÷ − 3mn =m n = m2 6 66. − a b ÷ − ab = a 2 − 1 1− 133 2b=a16. a x ÷ a 2 = a x − 27. 54x y z ÷ − 6xy z = − 9x2 − 1y 2 − 2z3 − 3 = − 9x 2 2 32 317. − 3a xbm ÷ ab 2 = − 3a x − 1bm − 28. − 5m2n ÷ m2n = − 5m2 − 2n1− 1 = − 55 m − 3 n − 4 1− 1 59. − 8a 2 x 3 ÷ − 8a 2 x 3 = a 2 − 2 x 3 − 3 = 118. 5a b c ÷ − 6a b c = −m n3 4a b c = − a m − 3bn − 466 xy 2 − 1xy10. − xy ÷ 2y = − =−21 x−m m−n19. a b ÷ − 4a b = − x mm n 2 2 a b 45 4 − 4 5 −1 511. 5x y ÷ − 6x y = − x y = − y44 54 a−x x−2 3−33 320. − 3m n x ÷ − 5m n x = m n xa x 3x 2 3 = m a − xnx − 2665 5EJERCICIO 502. 2x a + 4 ÷ − x a + 2 = − 2x a + 4 − b+ 2 g= − 2x a + 4 − a − 2 = − 2x 2 a1. am + 3 ÷ am + 2 = a m+3− m+2 b g= am + 3 − m − 2 = a 1 2n + 3 − b+ 4g 11 2n + 3÷ − 4xn + 4 = − = − x 2n + 3 − n − 4 = − xn − 1 n4. xx3 m − 2 − b − 5 g 3 m −2 − m + 5 3 3444m− 23. − 3a÷ − 5am − 5 = = a= ama5 55 m + 3 m −1 7 m + 3 − 4 m − 1− 2 7 m − 1 m − 36. − 7x y ÷ − 8x 4 y 2 =xy= x y x−2 n 4 x − 2 − 3 n −2 4 x − 5 n − 2 885. − 4a b ÷ − 5a b =b = a b3 2 a 55n −1 n +1 n −1 n +1 4 n − 1− n + 1 n + 1− n − 148. − 4x y ÷ 5x y = − x y =−5 5557. 5a2m − 1 x − 3 b ÷ − 6a 2m − 2 b x−4 = − a 2m −1− 2m + 2 b x − 3 − x + 4 = − ab6 6 5 1− m 2 − n 3 − x10. − 5ab c ÷ 6a b c = − 2 3m n x a b c9. am + nb x + a ÷ amba = am + n − mb x + a − a = anb x6EJERCICIO 511 1 2 2 2 2 3 2 2 x ÷ = x = x1. 23 2 4 5. − 2 x 4 y 5 ÷ − 2 = 9 x 4 y 5 = 2 x 4 y 5 = 1 x 4 y 539 2 1891 33 6. 3m4n5p 6 ÷ − m4np 5 = − 1 m4 − 4n5 − 1p 6 − 5 = − 9n4p 3 3 3 4 2 15 3− a b ÷ − a b = 5 a 3 − 2b1− 1 =a= a32. 5 5420 4757 2 5 6 5 5 68 2 − 1 5 − 5 6 − 6 = 14 a = 7 a27. − 8 a b c ÷ − 2 ab c = 5 a b c 40 20 2 5 3 1 3 12 5 2 xy z ÷ − z = − 3 xy 5 z 3 − 3 = −xy = − 4xy 53. 3 61 36 22 x m 3 2 10 x − 1 m − 27 8. a b ÷ − ab = − 3 a x − 1bm − 2 = −a b3 5 39 7 m n328 m − 1 n − 2 7 m − 1 n − 2 − a b ÷ − ab 2 = 8 a m − 1b n − 2 =a b = a b 54. 84 324 64
• 57. 311. − 2a x + 4bm − 3 ÷ − 1 a 4b 3 = 2 a x + 4 − 4bm − 3 − 3 = 4a xbm − 63 3 5 3 x21 − c d ÷ d =−8 c 3 d 5 − x = − 12 c 3 d 5 − x = − 1 c 3 d 5 − x9. 8 4 3 2422 4 1312. − a x − 3bm + 5 c 2 ÷ a x − 4bm −13 1553 m n 3 6 m n− 3 1 1a b ÷ − b 3 = − 4 a m b n− 3 = −a b = − a mb n − 310. 4 2 312251= − 15 a x − 3 − x + 4b m+ 5 − m + 1c 2 = −ab 6 c 2 = − ab 6 c 22345 9 5EJERCICIO 52a x + am − 1 a x am − 1a 2 − ab a 2 ab 10. = 2 + 2 = a x − 2 + am − 31. a − ab ÷ a = = − =a −b2a2 aaa a am+211. 2a − 3am+ 6am + 42. 3x y − 5a x ÷ − 3x 2 32 4 2 3x 2 y 3 − 5a 2 x 4 3x 2 y 3 5a 2 x 45 2 2− 3a 3 = =−= − y3 + a x − 3x 2− 3x 2 − 3x 23 2am 3am + 2 6am + 4 2= − += − am − 3 + am − 1 − 2am + 1− 3a 3 − 3a 3 − 3a 333. 3a − 5ab − 6a b 32 2 3m −1 n + 2 m−2 n+4 − 2a 12. a b + a b − a b m n 2 33a35ab 6a b2 3 5 2 3 ab =− − = − a 2 + b 2 + 3ab 3− 2a − 2a− 2a2 2ambn am − 1bn + 2 am − 2bn + 4= 2 3 +−ab a 2b 3a 2b 3 x 3 − 4x 2 + x x 3 4x 2 x4. = −+ = x 2 − 4x + 1= a b + a b − a m − 4 bn + 1 m−2 n−3m− 3 n−1xx x xm+213. x− 5 x m + 6 xm + 1 − x m − 15. 4x − 10x − 5x 8 64xm − 2 2x 3 m+2x 5x m 6x m + 1 x m − 14x 8 10x 6 5x 45= m−2 − m− 2 + m− 2 − m−2 = 3− − = 2x 5 − 5x 3 − x x x x x2x 2x 32x 32= x 4 − 5x 2 + 6x 3 − x ⇒ x 4 + 6 x 3 − 5 x 2 − x6. 6m − 8m n + 20mn 3 22x + 4 m−1 − 2m 14. 4a b− 6a x + 3 b m − 2 + 8a x + 2 b m − 36m3 8m2n 20mn2 − 2a x + 2 b m − 4 =− += − 3m2 + 4mn − 10n2− 2m − 2m − 2m 4a x + 4 b m − 16a x + 3 b m − 28a x + 2 b m − 3=x+2 m−4−x+2 m−4+− 2a b− 2a b− 2a x + 2b m − 47. 6a b − 3a b − a b 8 86 6 2 3 2 3= − 2a 2b 3 + 3ab 2 − 4b 3a b6a 8b 8 3a 6b6 a 2b 3 1 = 2 3− − = 2a 6b 5 − a 4b3 − EJERCICIO 533a b3a 2b3 3a 2b3 38. x − 5x − 10x + 15x43 2 1 2 2− 5x xx36 31. 2− 3 = x − = x −1x4 5x 3 10x 2 15x12 2 46 4 = −− + = − x 3 + x 2 + 2x − 3x x − 5x − 5 x− 5x − 5 x53 39. 8m n − 10m n − 20m n + 12m n9 2 7 45 63 81 3 3 2 1a aa 2m 23 −5+ 43 33 8m9n2 10m7n4 20m5n6 12m3n8 − −− = − −+ 2.5 552m2 2m22m2 2m2 5 3 15 2 5 55 = 4m n − 5m n − 10m n + 6mn 7 2 5 4 3 68=− a +a − a = − a 3 + a2 −a 915129 12
• 58. 2 33 2 2 1 m 1 m−13. 1 m 4 mnmn a a 222 1 33+4 = am − 1 + am − 2 = a m − 1 + a m − 2 4 −+ 86. 1 1 1 2 1 21 2aa343 2 m mm 4 4422 4 8 12 283= m2 − mn +n = m2 − mn + n22 x +1 1 x −12 x 4 38327.aa a 3− 4 − 51 x−2 1 x−2 1 x−2 2 4 31 3 41 2 5a aa4. x yx y x yxy 6 666 3− 5 + 4− 12 3 6 12 212 2 3 11 1 − xy 3 − xy 3 − xy 3 − xy 31=a − a− a ⇒ 4a 3 −a − a 55 5 5 3 45 5210 3 5 2 5 =− x + x y − xy 2 + 5y 33 n−1 m+ 2 1 n m +1 2 n +1 m 354 8. − a x axa x 4+ 8 −3 10 3 5 2 2 2 2 = − x + x y − xy + 5y 3 2− a 3x2 − a3x 2 − a 3x23 4 5 5 5 15 n − 4 m 5 n − 3 m − 1 10 n − 2 m − 2 2 51 3 3= a x − a x +a x aab8 16 65. 5ab 5 2 4 1 2 3 1 5 −3 − = a −ab − b15 n − 4 m 5 n − 3 m − 1 5 n − 2 m − 25a5a5a 25 15 5 = a x −a x+ a x8 16 3EJERCICIO 541. a + 2a − 3 2 a+36. a 2 + 5a + 6a+2 11. − 8a 2 + 12ab − 4b 2 −a +b − a 2 − 3aa −1 − a − 2a 2 a+3 + 8a 2 − 8ab8a − 4b − a−33a + 6 4ab − 4b 2 + a+3− 3a − 6− 4ab + 4b 22. a − 2a − 32 a +1 7.6x 2 − xy − 2y 2 2x + y− 6 x 2 − 3xy3x − 2y 12. 6m2 − 11 + 5n2 mnm−n −a −a 2 a−3 − 6m + 6mn26m − 5n − 3a − 3− 4 xy − 2y 2 + 3a + 3+ 4 xy + 2y 2− 5mn + 5n2+ 5mn − 5n23 . x + x − 202x+5 8. − 15 x 2 + 22 xy − 8y 2− 3 x + 2y − x 2 − 5x x−4+ 15x 2 − 10xy5x − 4y 13. − 54m + 12mn + 32n − 9m + 8n22 − 4x − 2012 xy − 8y 2 + 54m2 − 48mn6m + 4n + 4x + 20− 12xy + 8y 2− 36mn + 32n24.m − 11 + 30 2m m−6 9. 5a + 8ab − 21b 2 2a + 3b+ 36mn − 32n2 − m2 + 6mm−5− 5a 2 − 15ab5a − 7b − 5m + 30 − 7ab − 21b 2 14. − 14y 2 + 71y + 33 − 7y − 3 + 5m − 30 + 7ab + 21b 2 + 14y 2 + 6y2y − 11 + 77y + 335. x 2 − 8x + 15 −x+3 10.14x 2 + 22x − 12 7x − 3 − 77y − 33 − x + 3x 2 −x+5− 14x + 6x 22x + 4 − 5x + 15 28x − 12 + 5x − 15− 28x + 12
• 59. 15.x3− y3 x − y 21.3y 5 − 12y + 5y 2 + 10y2 + 2−x +x y3 2x 2 + xy + y 2− 3y − 6 y5 3 3y 3 − 6 y + 52x y − 6y 3 − 12y − x 2 y + xy 2 + 6y 3 + 12y xy − y2 3 5y 2 + 10 − xy + y23− 5y 2 − 1016.a 3 − 3a 2b + 3ab 2 − b 3 a − b am4 − am − 2aam + a− a 3 + a 2ba 2 − 2ab + b 2 22.− am4 − am3 m3 − m2 + m − 2 − 2a 2b + 3ab2− am3 + 2a 2b − 2ab 2+ am3 + am2 ab 2 − b3 am2 − am− ab 2 + b3− am2 − am17. x 4− 9x 2 +x+3 x+3 − 2am − 2a− x 4 − 3x 3x 3 − 3x 2 + 1+ 2am + 2a − 3x 3 − 9 x 2 + 3x 3 + 9x 223.12a 3 − 35a 2b + 33ab 2 − 10b 3 4a − 5bx+3 − 12a 3 + 15 a 2b 3a 2 − 5ab + 2b 2 −x−3− 20a 2b + 33ab 218.a 4 +a a +1+ 20a 2b − 25ab 2−a − a 43a −a +a32 8ab 2 − 10b 3 −a 3− 8ab 2 + 10b 3 +a +a32a2 + a24. 15m5 − 5m4n − 9m3n2 + 3m2n3 + 3mn4 − n5 3m − n−a −a 2 − 15m + 5m n545m4 − 3m2n2 + n4 − 9m3n2 + 3m2n319. m6− n6 m 2 − n2 + 9m3n2 − 3m2n3− m 6 + m 4 n2m4 + m2n2 + n43mn4 − n5m 4n2 − 3mn4 + n5 − m4n2 + m2n4m2n4 − n6− m2n4 + n6EJERCICIO 5520. 2x − x + 7x − 3 2x + 343− 2x 4 − 3x 3 x 3 − 2x 2 + 3x − 11. a 4− a 2 − 2a − 1a2 + a + 1 − 4x 3− a4 − a3 − a2 a2 − a − 1 + 4 x 3 + 6x 2− a − 2a − 2a32 6x 2 + 7 x+ a3 + a 2 + a− 6x 2 − 9x− a2 − a − 1 − 2x − 32x + 3+ a2 + a + 1
• 60. 2. x 5 + 12x 2 − 5xx 2 − 2x + 58. − x + 3x y 43 − 5xy 3 + 3y 4x 2 − 2xy + y 2 − x + 2x − 5 x5 43 x 3 + 2x 2 − x+ x − 2x y + x y43 2 2 − x 2 + xy + 3y 2 2 x − 5 x + 12x432 x 3 y + x 2 y 2 − 5xy 3 − 2x 4 + 4 x 3 − 10x 2 − x 3 y + 2x 2 y 2 − xy 3− x + 2x − 5x 32 3x 2 y 2 − 6xy 3 + 3y 4+ x − 2x + 5 x 32 − 3x 2 y 2 + 6xy 3 − 3y 43.m5 − 5m4n + 20m2n3 − 16mn 4m2 − 2mn − 8n 2 9.n4 − 2n3 + 2n − 1 n2 − 2n + 1 − m + 2m n + 8m n 5432m − 3m n + 2mn3 2 2 − n4 + 2n3 − n2 n2 − 1 − 3m4n + 8m3n 2 + 20m2n 3 − n2 + 2n − 1+ 3m4n − 6m3n 2 − 24m2n 3 + n2 − 2n + 1 2m3n2 − 4m2n 3 − 16mn 4 − 2m3n 2 + 4m2n 3 + 16mn 410. a 5b − 5a 4b 2 + 22a 2b 4 − 40ab 5 a 2b − 2ab 2 − 10b 3− a b + 2a b + 10a b 5 4 2 3 3a 3 − 3a 2b + 4ab 24. x4 − x 2 − 2x − 1x2 − x −1 − 3a b + 10a b + 22a b4 23 3 2 4 − x 4 + x 3 + x2 x2 + x + 1 + 3a 4b 2 − 6a 3b 3 − 30a 2b 4 +x 3 − 2x4a 3b 3 − 8a 2b 4 − 40ab 5 − x 3 + x2 + x− 4a 3b 3 + 8a 2b 4 + 40ab 5x − x −1 2− x2 + x + 111. 16x 4− 24x 2 y 2 − 27y 4 8x 3 − 12x 2 y + 6xy 2 − 9y 3− 16x + 24x y − 12x y + 18xy 43 2 232 x + 3y5. x − 2x+ 6x 3 − 7 x 2 − 4x + 6 x 4 − 3x 2 + 224 x 3 y − 36x 2 y 2 + 18xy 3 − 27y 46 5 − x6 + 3x 4− 2x 2x 2 − 2x + 3 − 24 x 3 y + 36x 2 y 2 − 18xy 3 + 27y 4 − 2x 5 + 3x 4 + 6x 3 − 9x 2 − 4 x+ 2x 5 − 6x3 + 4x12. 4y + 4y − 13y − 3y − 202y + 543 2 3x4− 9x 2+6− 4y 4 − 10y 3 2y 3 − 3y 2 + y − 4− 3x 4+ 9x 2−6− 6y 3 − 13y 2+ 6y 3 + 15y 26. m6 + m5 − 4m4+ m2 − 4m − 1m3 + m2 − 4m − 12y 2 − 3y − m6 − m5 + 4m4 + m3m3 + 1− 2y 2 − 5y − 20m3 + m2 − 4m − 1 − 8y − 20 − m3 − m2 + 4m + 1 8y + 207.a5 − a 4 + 7a 2 − 27a + 10 a2 − a + 513. − 2a − 3a x + 5a x− 11ax 4 − 3x 5− a 3 + 2ax 2 + 3x 3543 2 − a + a − 5a 543 a 3 − 5a + 2+ 2a 5− 4a x − 6a x3 2 23 2a 2 − 3ax − x 2− 5a + 7a − 27a 323a 4 x + a 3 x 2 − 6a 2 x 3 − 11ax 4+ 5a 3 − 5a 2 + 25a− 3a 4 x+ 6a 2 x 3 + 9ax 4 2a − 2a + 1023a x2− 2ax 4 − 3x 5−a x 3 2+ 2ax 4 + 3x 5 − 2a 2 + 2a − 10
• 61. 14. − x + 2x y− 3x 2 y 4 − xy 5 x 4 − 3x 3 y + 2x 2 y 2 + xy 3 65+ x − 3x y + 2x y + x y 654 2 3 3 − x 2 − xy − y 2 − x y + 2x y + x y − 3x y54 2 3 32 419. y − 2y − y + 4y− 4y + 2 y 4 − 2y 2 + 2 65 4 3 + x 5 y − 3x 4 y 2 + 2x 3 y 3 + x 2 y 4 −y6 + 2y4 − 2y2y 2 − 2y + 1− x y + 3x y − 2 x y − xy 4 23 32 4 5 − 2y 5 + y 4 + 4 y 3 − 2y 2 − 4 y+ x 4 y 2 − 3x 3 y 3 + 2x 2 y 4 + xy 5 + 2y 5− 4y 3+ 4y y 4− 2y 2+215. a − 5a + 31a 2 − 8a + 21a 3 − 2a − 7 6 5 − y4 + 2y 2−2−a 6 + 2a + 7a 4 3a − 5a + 2a − 332 − 5a + 2a + 7a + 31a54 3220. 3m7 − 11m5 + m4 + 18m3 − 3m2 − 8m + 4m4 − 3m2 + 4 + 5a 5− 10a 3 − 35a 2 − 3m7 + 9m5 − 12m33m3 − 2m + 12a 4 − 3a 3 − 4a 2 − 8a− 2m5 + m4 + 6m3 − 8m− 2a 4 + 4a 2 + 14a + 2m5 − 6m3+ 8m − 3a 3+ 6a + 21m4 − 3m2+4 + 3a 3− 6a − 21 − m4+ 3m2−416. m6 − m5+ 5m3 − 6m + 9 m 4 + m3 − m2 + 321.a 6 + 2a 5 − 2a 4 − 3a 3 + 2a 2 − a − 1a3 + a2 − a + 1− m6 − m5 + m 4− 3m2m2 − 2m + 3 − a6 − a5 + a4 − a3 a 3 + a 2 − 2a − 1 − 2m5 + m4 + 5m3 − 3m2 − 6m a 5 − a 4 − 4a 3 + 2a 2 + 2m5 + 2m4 − 2m3+ 6m − a5 − a4 + a3 − a2 3m4 + 3m3 − 3m2+9− 2a 4 − 3a 3 + a 2 − a− 3m4 − 3m3 + 3m2 −9+ 2a 4 + 2a 3 − 2a 2 + 2a − 117. a 6 − a 5b − 4a 4b 2 + 6a 3b 3− 3ab 5 + b 6 a 2 − 2ab + b 2 − a3 − a2 + a − 1− a + 2a b − a b 654 2a + a b − 3a b − ab + b 4 322 34+ a3 + a2 − a + 1 a b − 5a b + 6a b54 23 3− a 5b + 2a 4b 2 − a 3b 3 22. 24 x 5 − 52x 4 y + 38x 3 y 2 − 33x 2 y 3 − 26xy 4 + 4y 5 8 x 3 − 12x 2 y − 6xy 2 + y 3 − 3a 4b 2 + 5a 3b 3− 24x 5 + 36x 4 y + 18x 3 y 2 − 3 x 2 y 3 3x 2 − 2xy + 4 y 2 + 3a 4 b 2 − 6a 3b 3 + 3a 2b 4 − 16x y + 56x y − 36x y − 26xy43 2 2 3 4 − a 3b 3 + 3a 2b 4 − 3ab 5+ 16x 4 y − 24x 3 y 2 − 12x 2 y 3 + 2xy 4 + a 3b 3 − 2a 2b 4 + ab 532x 3 y 2 − 48x 2 y 3 − 24xy 4 + 4 y 5 a b − 2ab + b 24 56− 32x 3 y 2 − 48x 2 y 3 + 24xy 4 − 4 y 5− a b + 2ab − b2 4 5618. x6− 2 x 4 y 2 + 2x 3 y 3 − 2x 2 y 4 + 3xy 5 − 2y 6 x 2 + xy − 2y 2− x − x y + 2x 4 y 2 65 x 4 − x 3 y + x 2 y 2 − xy 3 + y 4 −x y5 + 2x y3 3x 5 y + x 4 y 2 − 2x 3 y 3 23. 5a 8 − 4a 7 − 8a 6 + 5a 5 + 6a 4 − 2a 3 + 4a 2 − 6a a 4 − 2a 2 + 2− 5a 8 + 10a 6 − 10a 4 5a 4 − 4a 3 + 2a 2 − 3a + x4y2 − 2x 2 y 4 − 4a + 2a + 5a − 4a − 2a 765 4 3 − x 4 y 2 − x 3 y 3 + 2x 2 y 4 + 4a 7 − 8a 5 + 8a 3 − x3y3+ 3xy 5 + 2a 6 − 3a 5 − 4a 4 + 6a 3 + 4a 2 + x 3 y 3 + x 2 y 4 − 2xy 5 − 2a 6+ 4a 4− 4a 2 x 2 y 4 + xy 5 − 2y 6− 3a 5 + 6a3− 6a− x2y4− xy 5 + 2y 6 3a 5− 6a 3 + 6a
• 62. 24. x − 3x + 6x + x 2 − 3x + 6 x 3 − 2x 2 + 3x + 6 76 5− x 7 + 2 x 6 − 3x 5 − 6x 4 x 4 − x 3 + x2 − x + 1 − x + 3x − 6 x654+ x 6 − 2x 5 + 3x 4 + 6x 329. 3a 9 − 15a 7 + 14a 6 − 28a 4 + 47a 3 − 28a 2 + 23a − 10 3a 5 − 6a 3 + 2a 2 − 3a + 2x − 3x + 6x + x 54 3 2 − 3a + 6a − 2a + 3a − 2a 4 97 65a 4 − 3a 2 + 4a − 5− x + 2x − 3x − 6 x − 3x 5 43 2 − 9a + 12a + 3a − 30a + 47a − 28a7 6 5432 − x 4 + 3x 3 − 5x 2 − 3x+ 9a 7 − 18a 5 + 6a 4 − 9a 3 + 6a 2 + x − 2x + 3x + 6 x + 64 3 2+ 12a 6 − 15a 5 − 24a 4 + 38a 3 − 22a 2 + 23ax − 2x3 2+ 3x + 6− 12a 6 + 24a 4 − 8a 3 + 12a 2 − 8a − x + 2 x − 3x − 63 2− 15a5 + 30a 3 − 10a 2 + 15a − 10+ 15a 5 − 30a 3 + 10a 2 − 15a + 1025.3a + 5a − 9a − 10a + 8a + 3a − 4 3a + 2a − 5a − 46 543 232− 3a 6 − 2a 5 + 5a 4 + 4a 3a 3 + a 2 − 2a + 130. a 2 − b2+ 2bc − c 2a+b−c − a 2 − ab + ac a−b+c+ 3a − 4a − 6a + 8a5 4 3 2− 3a 5 − 2a 4 + 5a 3 + 4a 2− ab − b 2 + ac + 2bc + ab + b 2− bc− 6a 4 − a 3 + 12a 2 + 3a+ 6a + 4a − 10a − 8a4 3 2 ac + bc − c 2− ac − bc + c 23a 3 + 2a 2 − 5a − 4− 3a 3 − 2a 2 + 5a + 431. − 2x + 5xy − xz − 3y − yz + 10z 2x − 3y + 5z2 22 + 2 x 2 − 3xy + 5 xz− x + y + 2z26.5y 8 − 3y 7 − 11y 6 + 11y 5 − 17y 4 − 3y 3 − 4y 2 − 2y 5y 4 − 3y 3 + 4y 2 + 2y− 5y + 3y − 4y − 2y8 7 6 5y − 3y − 1 422 xy + 4 xz − 3y 2 − yz− 2xy + 3y 2 − 5yz− 15y 6 + 9y 5 − 17y 4 − 3y 3+ 15y − 9y + 12y + 6y6 5 4 34 xz − 6yz + 10z 2− 5y 4 + 3y 3 − 4 y 2 − 2y − 4 xz+ 6yz − 10z 2+ 5y − 3y + 4y + 2y4 3227. − m7 + 5m6n − 14m5n2 + 20m4n3 − 13m3n4 − 9m2n5 + 20mn6 − 4n7 − m3 + 3m2n − 5mn2 + n3+ m7 − 3m6n + 5m5n 2 − m4n 3 m4 − 2m3n + 3m2n 2 − 4n 4 2m6n − 9m5n 2 + 19m4n 3 − 13m3n 4 − 2m6n + 6m5n2 − 10m4n 3 + 2m3n4 − 3m5n 2 + 9m4n 3 − 11 3n 4 − 9m2n 5 m + 3m5n 2 − 9m4n 3 + 15m3n 4 − 3m2n 54m3n 4 − 12m2n5 + 20mn 6 − 4n 7− 4m3n 4 + 12m2n 5 − 20mn 6 + 4n 728. x11 − 5x 9 y 2 + 8x 7 y 4 − 6 x 5 y 6 − 5x 3 y 8 + 3xy10 x 5 − 2x 3 y 2 + 3xy 4− x11 + 2x 9 y 2 − 3x 7 y 4 x 6 − 3x 4 y 2 − x 2 y 4 + y 6− 3x 9 y 2 + 5x 7 y 4 − 6 x 5 y 6 32. x 3+ y3− 3xyz + z 3x 2 − xy − xz + y 2 − yz + z 2+ 3x 9 y 2 − 6x 7 y 4 + 9 x 5 y 6 − x3 + x 2y + x2z − xy 2 + xyz− xz 2 x+y+z − x 7 y 4 + 3x 5 y 6 − 5x 3 y 8 x 2 y + x 2 z + y 3 − xy 2 − 2 xyz + z 3 − xz 2 + x 7 y 4 − 2 x 5 y 6 + 3x 3 y 8− x2 y − y 3 + xy 2 + xyz + y 2 z − yz 2+ x 5 y 6 − 2 x 3 y 8 + 3xy 10 2x z − xyz + z − xz + y 2 z − yz 23 2− x 5 y 6 + 2 x 3 y 8 − 3xy 10−x z 2+ xyz − z 3 + xz 2 − y 2 z + yz 2
• 63. 33. a 5+ b5 a + b−a −a b 5 4 a 4 − a 3b + a 2b 2 − ab 3 + b 4 − a 4b37. x15+ y 15 x3 + y 3 + a 4b + a 3b 2 −x −x y 1512 3 x12 − x 9 y 3 + x 6 y 6 − x 3 y 9 + y 12 3 2 a b−x y123− a 3b 2 − a 2b 3 x12 y 3 + x 9 y 6 −a b 23x9y6 + a 2b 3 + ab 4− x9y 6 − x6y 9ab 4 + b 5− x6y 9 − ab 4 − b 5 x 6 y 9 + x 3 y 12x 3 y12 + y1534. 21x5 − 21y 5 3x − 3y− x 3 y 12 − y 15− 21x + 21x y 54 7 x + 7 x y + 7 x y + 7 xy + 7 y 4 3 22 3 4 21x 4 y − 21x 4 y + 21x 3 y 2 38. x 3 + 3x 2 y + 3xy 2 + y 3 − 1x 2 + 2xy + x + y + y 2 + 1 − x − 2x y − xy 3 22− x − xy − x2 x + y −1 21x 3 y 2x 2 y + 2 xy 2 + y 3 − 1− x 2 − xy − x − 21x 3 y 2 + 21x 2 y 3− x 2 y − 2xy 2 − y 3 − xy − y2 − y 21x 2 y 3− 1− x − 2xy − x − y 2 − y2− 21x 2 y 3 + 21xy 4+ 1+ x 2 + 2xy + x + y 2 + y 21xy 4 − 21y 5 − 21xy 4 + 21y 516x 8− 16y 8 2x 2 + 2y 235.− 16x − 16x y 8 6 2 8x 6 − 8 x 4 y 2 + 8x 2 y 4 − 8y 6 − 16x 6 y 2 + 16x 6 y 2 + 16x 4 y 4 39. x 5+ y5x 4 − x 3 y + x 2 y 2 − xy 3 + y 4 − x + x y − x y + x y − xy 5 43 2 2 3 4x+y16x 4 y 4 − 16x y − 16x y 4 4 2 6 x 4 y − x 3 y 2 + x 2 y 3 − xy 4 + y 5 − x 4 y + x 3 y 2 − x 2 y 3 + xy 4 − y 5 − 16x 2 y 6 − 16y 8 + 16x 2 y 6 + 16y 836. x 10 − y 10x2 − y2− x10 + x 8 y 2x8 + x6y2 + x4y 4 + x2y6 + y8 x8y2 − x8y2 + x6y4EJERCICIO 5664x y− x6y 4 + x 4 y6ax+3 + ax a +11.x4 y 6− ax +3 − ax +2a x + 2 − a x +1 + a x − x 4y 6 + x2y 8 −ax+2 x 2 y 8 − y 10 + a x + 2 + a x +1 − x 2 y 8 + y 10 a x +1 + a x− a x +1 − a x
• 64. 2. − x n + 5 + xn + 4 + 3xn + 3 + x n + 2x2 + xn+ 5n+ 4 +x+x− x n + 3 + 2x n + 2 + x n + 1 + 2x n+ 4+ 3x n+ 38. − m2a + 3 + 2m2a + 2 + 2m2a + 1 − 4m2a − m2a − 1 + m2a − 2 − ma − 1 + ma − 2 + ma − 3 − 2x n+ 4− 2x n+ 3+ m 2 a + 3 − m2 a + 2 − m 2 a + 1ma + 4 − ma + 3 − 2ma + 2 + ma + 1+ m2a + 2 + m2a + 1 − 4m2a xn + 3 + x n + 2− xn+ 3 − xn+ 2 − m2a + 2+ m2a +1 + m2a2m2a + 1 − 3m2a − m2a − 1 − 2m2a + 1 + 2m2a + 2m2a − 13. ma + 4 − ma + 3+ 6ma + 1 − 5ma + 3ma − 1m2 − 2m + 3− m 2 a + m2 a − 1 + m 2 a − 2 − ma + 4 + 2ma + 3 − 3ma + 2ma + 2 + ma + 1 − m a + ma − 1 + m 2 a − m2 a − 1 − m2 a − 2 ma+3− 3m a+2 + 6ma +1− ma + 3 + 2ma + 2 − 3ma + 19.x 2a − 2 + x 2a − 3 − 4x 2a − 4− x 2a − 7 x a − 1 − x a −2 − x a − 3− ma + 2 + 3ma + 1 − 5ma− x 2a − 2 + x 2a − 3 + x 2a − 4 x a − 1 + 2x 2 a − 2 − x a − 3 + x a − 4+ ma + 2 − 2ma + 1 + 3ma+ 2x2a − 3 − 3x 2a − 4ma + 1 − 2ma + 3ma − 1− 2 x 2 a − 3 + 2x 2 a − 4 + 2x 2 a − 5 − ma + 1 + 2ma − 3ma − 1 − x 2a − 4 + 2x 2a − 5 + x 2a − 4 − x 2a − 5 − x 2a − 64. a 2n + 3 + 4a 2n + 2 + a 2n + 1 − 2a 2n a n + 1 + a n+ x 2a − 5 − x 2a − 6 − x 2a − 7 − a 2 n + 3 − a 2n + 2 a n + 2 + 3a n + 1 − 2a n− x 2a − 5 + x 2a − 6 + x 2a − 73a 2n + 2 + a 2n + 1− 3a 2n + 2 − 3a 2n + 1 2n −1 4 2n − 2 5 − 2a 2n − 4b 7 + a 2n − 5b 8 a nb − a n − 1b 2 + 2a n − 2b 3 − a n − 3b 4 10. a b − a b + a b2n 3 − 2a2n +1 − 2a2n−a b +a 2n32n − 1 4b − 2a2n − 2 b +a 5 2n − 3 b6 a nb 2 − a n − 2 b 4 2a 2n + 1 + 2a 2n −a 2n − 2 b +a 5 2n − 3b − 2a 6 2n − 4b +a72n − 5b 8 + a 2n − 2b 5 − a 2n − 3b 6 + 2a 2n − 4b 7 − a 2n − 5b 85. x 2 a + 5 + 2 x 2 a + 4 − 3x 2 a + 3 − 4x 2 a + 2 + 2x 2 a + 1 x a + 3 − 2x a + 1 − x 2a + 5 + 2x 2 a + 3x a + 2 + 2x a + 1 − x a+ 2x 2a + 4−x 2a + 3 11.a m + x + a mb x + a x b m + b m + xax + bx− 2x 2a + 4 + 4x 2 a + 2− a m + x − a mb xa m + bm− x 2a + 3+ 2x 2 a + 1a b +bxmm+ x+ x 2a + 3− 2x 2 a + 1− a xb m − b m + x6. ax+2 − 2a x + 8a x − 1 − 3a x − 2a x − 2a x − 1 + 3a x − 2 −a x+2+ 2a x +1− 3a xa 2 + 2a − 12a x + 1 − 5a x + 8a x − 1 12. a x − a x − 1b + b n − ab n − 1 a−b− 2ax +1+ 4a − 6a xx −1− a x + a x − 1b a x −1 − b n − 1n−1− a x + 2a x − 1 − 3a x − 2b − ab n+ a − 2a x x −1+ 3ax−2 − b n + ab n − 17. a 2 x + 2a 2 x − 1 − 4a 2 x − 2 + 5a 2 x − 3 − 2a 2x − 4a x − a x −1 + a x − 2 − a 2 x + a 2 x − 1 − a 2x − 2a x + 3a x − 1 − 2a x − 23a 2 x − 1 − 5a 2x − 2 + 5a 2 x − 3 13.3a 5m − 3 − 23a 5m − 2 + 5a 5m − 1 + 46a 5m − 30a 5m + 1 a 3m − 3 − 8a 3m − 2 + 6a 3m − 1 − 3a 2 x − 1 + 3a 2 x − 2 − 3a 2 x − 3− 3a 5m − 3 + 24a 5m − 2 − 18a 5m − 1 3a 2m + a 2m + 1 − 5a 2m + 2 − 2a 2 x − 2 + 2a 2 x − 3 − 2a 2 x − 4 + a 5m − 2− 13a5m − 1+ 46a 5m + 2a 2 x − 2 − 2a 2 x − 3 + 2a 2 x − 4 − a 5m − 2 + 8a 5m − 1 − 6a 5m− 5a 5m − 1 + 40a 5m − 30a 5m + 1 5a 5m − 1 − 40a 5m + 30a 5m + 1
• 65. 14. 2x 3a + 1y 2x − 3 − 4x 3a y 2 x − 2− 28x 3a − 2 y 2 x + 30x 3a − 3y 2 x + 1 − x a + 2 y x − 1 + 4 x a + 1y x − 3x a y x + 13a + 1 2 x − 33a 2 x − 23a − 1 2 x − 1 − 2x y+ 8x y− 6xy − 2x 2a − 1y x − 2 − 4 x 2a − 2 y x − 1 − 10x 2a − 3y x + 4 x 3a y 2 x − 2 − 6x 3a − 1y 2x − 1 − 28x 3a − 2 y 2 x− 4x 3a y 2 x − 2 + 16x 3a − 1y 2x − 1 − 12x 3a − 2 y 2 x 10x 3a − 1y 2x − 1 − 40x 3a − 2 y 2x + 30x 3a − 3 y 2 x + 1− 10x 3a − 1y 2 x − 1 + 40x 3a − 2 y 2 x − 30x 3a − 3 y 2 x + 1EJERCICIO 57 1 2 5 1 1 11.a +ab − b 2a+ b6 36 6 3 2 3 4 1 3 17 2 2 7 3 2 5.m +m n−m n + mn 3 − n 4m − mn + 2n 21 11 1 5 106062 − a 2 − aba− b3 4 2 34 2 22 2 116 42 3− m + m n−m nm + mn − n2 5 555 32 1 1−ab − b 21 365 2 2 7 9 6 m n−m n + mn3 2606 1 1 ab + b 21 31 2 2 2− m n + m n − mn 3 9 6 23 33 2 211 2 712 − m n +mn3 − n42.x +xy − y 2 x−y 423 10 35 3 2 21m n −mn3 + n 41 21 542 − x2 + xy x+ y 3 153 65 13 5 1 4 37 3 2 2 1941xy − y 2 6.x + x −x + x +x− 2x 3 − x+26 342403305351 3 51 3 3 23 2 1 2 − xy + y 2 − x+x − xx + x−6 3484 8 4 5 1 4 4 3 1 2 19 x − x −x +x1 3 35 2 2 2 3 31 2 1 12512 303.x −x y+xy − y x − xy + y 23 36 3 82 3 411 21− x4 +x −x1 32 2 1 223 2 122 − x + x y−xy x− y39 6324 3 2 4− x+x−3 21 2 3 3515 5− x y+ xy − y42 84 32 4x − x+3 21 2 3 35 15 5x y− xy + y42 8 911313 2 21 3 5 25 1 37.a 4 − a 3x −a 2x 2 +ax 3 − x 4a − ax + x 24.a − a b + ab 2 − b 3 a− b 41218 3 2 3 168 3429 4 3 3 3 2 1 1 − a + a x− a x 2 2a + ax − x 21 3 3 21 2 2422 3 2 −a + ab a − ab + b 2 168 4 3 1 313 2 2 13 3 a x−a x +ax 1 5 2 212 18− a 2b + ab1 1 2 22 3 4 3− a3x +a x −ax 2 39 1 2 3 2 ab− ab 3 2 2 1 3 1 4 4 2− a x + ax − x4231 2 3 2 2 1 3 1 4ab − b 3a x − ax + x6 4231 − ab 2 + b36
• 66. 1 5 101 4139 3 2 1 2 3 52 3 1 2 18.x − x y+ x y − x y +xy 4x − x y + xy 2 14 420280212 7521 5 1 4 1 3 2 1 2 25 −x + x y−x y x − xy + y 2 1420 8 43 6 4 4 13 3 2 1 2 3 −x y+x y − x y 21352 3 5 21 4 47 3 79 2 11 1 3 1 2 1 1 9.x +x − x + x +x−x + x − x+ 4 42 3 2 1 2 38 40 120 120 1010 4 342 +x y−x y + x y 21153 3 1 3 3 3 2 3 2 11− x5 − x4 +x − x x +x− x 5 3 2 1 2 3 5 8 2 8 4 2 10 5x y − x y +xy 4 216121 41 311 2 1x −x − x +x5 3 2 1 2 3 540 60 120 10 −x y + x y −xy 4 216121 41 3 1 2 1 −x −x + x −x 40 3040 20 1 3 1 2 11 − x − x +x−2015 2010 1 31 2 1 1 x +x − x+20 152010 1 5 5 499 3 2 101 2 3 7 53 3 1 22110.m − m n+m n −m n + mn4 − n5m − m n + mn 2 − n3 26 40 606 842 54 1 5 1 4 4 3 21 2 3 2 2 25− m + m n− m n +m n m − mn + n2 23 156 33 21 453 3 2 91 2 3 7− m n+m n −m n + mn 4224 6061 4 1 3 24 2 3 1m n−m n +m n − mn42 3 15615 3 2 5 2 3 5 5 m n − m n + mn 4 −n 8 4 815 3 2 5 2 3 5−m n + m n −mn4 + n5 8 4 8EJERCICIO 581. x 5 − x 4 + x 2 − x ÷ x 3 − x 2 + x 1− 1+ 0 + 1− 1 1 − 1+ 13. a 6 + a 5b − 7a 4b 2 + 12a 3b 2 − 13a 2 b 4 + 7ab 5 − b 6 ÷ a 2 − 2ab + b 2 − 1+ 1− 1 1+ 0 − 11+ 1− 7 + 12 − 13 + 7 − 1 1− 2 + 1 − 1+ 1− 1 ⇒ x2 − 1− 1+ 2 − 11+ 3 − 2 + 5 − 1 + 1− 1+ 13 − 8 + 12⇒ a 4 + 3a 3b − 2a 2b2 + 5ab 3 − b 4 −3+6− 32. x 7 + x 6 − 11x 5 + 3x 4 − 13x 3 + 19x 2 − 56 ÷ x 3 − 2x 2 − 7 − 2 + 9 − 13 1+ 1− 11+ 3 − 13 + 19 + 0 − 56 1− 2 + 0 − 7 2− 4+ 2 − 1+ 2 − 0 + 7 1+ 3 − 5 + 0 + 85 − 11 + 73 − 11+ 10 − 13⇒ x 4 + 3x 3 − 5x 2 + 8 − 5 + 10 − 5 − 3 + 6 − 0 + 21− 1 + 2 −1 − 5 + 10 + 8 + 19+ 1 − 2 +1 + 5 − 10 + 0 − 358 − 16 + 0 − 56 − 8 + 16 − 0 + 56
• 67. 4. m − 5m n + 2m n + 20m n − 19m n − 10mn − n ÷ m − 4mn − n 654 23 32 4 5 6 3 23 1− 5 + 2 + 20 − 19 − 10 − 11+ 0 − 4 − 1 − 1− 0 + 4 + 1 1− 5 + 6 + 1 − 5 + 6 + 21 − 19 ⇒ m3 − 5m2n + 6mn2 + n3 5 + 0 − 20 − 5 6 + 1 − 24 − 10 8. m28 − 12m 24 + 53m20 − 127m16 + 187m12 − 192m8 + 87m 4 − 45 ÷ m12 − 7m 8 + 9m4 − 15 − 6 − 0 + 24 + 61− 12 + 53 − 127 + 187 − 192 + 87 − 451− 7 + 9 − 151 + 0 − 4 −1 − 1+ 7 − 9 + 151− 5 + 9 − 4 + 3 −1 − 0 + 4 +1− 5 + 44 − 112 + 187 ⇒ m16 − 5m12 + 9m8 − 4m4 + 3+ 5 − 35 + 45 − 755. x 8 − 2x 6 − 50x 4 + 58x 2 − 15 ÷ x 4 + 6x 2 − 59 − 67 + 112 − 192 1− 2 − 50 + 58 − 15 1+ 6 − 5− 9 + 63 − 81 + 135 − 1− 6 + 51− 8 + 3− 4 + 31 − 57 + 87 − 8 − 45 + 58 ⇒ x 4 − 8x 2 + 3 + 4 − 28 + 36 − 60 + 8 + 48 − 40 3 − 21 + 27 − 45 3 + 18 − 15 − 3 + 21 − 27 + 45 − 3 − 18 + 156. a14 − 7a12 + 9a10 + 23a 8 − 52a 6 + 42a 4 − 20a 2 ÷ a 8 − 4a 6 + 3a 4 − 2a 2 1− 7 + 9 + 23 − 52 + 42 − 20 1− 4 + 3 − 2− 1+ 4 − 3 + 2 1− 3 − 6 + 10 9. 2x 7 − 6x 6 y − 8x 5 y 2 − 20x 4 y 3 − 24x 3 y 4 − 18x 2 y 5 − 4 y 7 ÷ 2x 2 + 4 y 2− 3 + 6 + 25 − 52⇒ a − 3a 4 − 6a 2 + 106 2 − 6 − 8 − 20 − 24 − 18 + 0 − 42+0 +4 3 − 12 + 9 − 6−2−0− 41− 3 − 6 − 4 + 0 − 1 − 6 + 34 − 58 + 42− 6 − 12 − 20 ⇒ x 5 − 3x 4 y − 6x 3 y 2 − 4x 2 y 3 − y 5 + 6 − 24 + 18 − 12 6 + 0 + 1210 − 40 + 30 − 20 − 12 − 8 − 24− 10 + 40 − 30 + 20 + 12 + 0 + 24 − 8 + 0 − 187. 3x − 20 x + 51x − 70 x + 46 x − 20 ÷ 3x − 8 x + 10 15 12 963 63 + 8 + 0 + 16 3 − 20 + 51 − 70 + 46 − 20 3 − 8 + 10− 2+0−4 − 3 + 8 − 10 1− 4 + 3 − 22+0+ 4 − 12 + 41 − 70 ⇒ x 9 − 4 x 6 + 3x 3 − 212 − 32 + 40 9 − 30 + 4610. 6a 9 − 12a 7 + 2a 6 − 36a 5 + 6a 4 − 16a 3 + 38a 2 − 44a + 14 ÷ a 4 − 2a 2 + a − 7 − 9 + 24 − 306 + 0 − 12 + 2 − 36 + 6 − 16 + 38 − 44 + 14 1+ 0 − 2 + 1− 7 − 6 + 16 − 20 − 6 − 0 + 12 − 6 + 426+0+0−4+6−2 6 − 16 + 20− 4 + 6 + 6 − 16 + 38⇒ 6a 5 − 4a 2 + 6a − 2+ 4 + 0 − 8 + 4 − 286 − 2 − 12 + 10 − 44− 6 − 0 + 12 − 6 + 42− 2 + 0 + 4 − 2 + 14+ 2 − 0 − 4 + 2 − 14
• 68. 11. n − 6n + 5n + 13n − 23n − 8n + 44n − 12n − 32n + 16 ÷ n − 3n + 5n − 8n + 4 10876 5 4 3 2 64 31+ 0 − 6 + 5 + 13 − 23 − 8 + 44 − 12 − 32 + 16 1+ 0 − 3 + 5 + 0 − 8 + 4 − 1− 0 + 3 − 5 − 0 + 8 − 41+ 0 − 3 + 0 + 4 − 3 + 0 + 13 − 15 − 12 + 44 − 12⇒ n4 − 3n2 + 4 + 3 + 0 − 9 + 15 + 0 − 24 + 1212. 3x 7 − 4 x 6 y − 15x 5 y 2 + 29x 4 y 3 − 13x 3 y 4 + 5xy 6 − 3y 7 ÷ x 3 − 5xy 2 + 3y 3 4 + 0 − 12 + 20 + 0 − 36 + 163 − 4 − 15 + 29 − 13 + 0 + 5 − 31+ 0 − 5 + 3 − 4 + 0 + 12 − 20 − 0 + 36 − 16− 3 − 0 + 15 − 93 − 4 + 0 + 0 −1 − 4 + 0 + 20 − 13⇒ 3x 4 − 4 x 3 y − y 4 + 4 + 0 − 20 + 12 − 1+ 0 + 5 − 3 1 −0−5+313. x16 − 4x14 y 2 − 10x12 y 4 + 21x10 y 6 + 28x 8 y 8 − 23x 6 y10 + 9x 4 y12 + 33x 2 y14 − 6y16 ÷ x 6 − 4x 4 y 2 − 5x 2 y 4 + y 61− 4 − 10 + 21+ 28 − 23 + 9 + 33 − 6 1− 4 − 5 + 1− 1+ 4 + 5 − 1 1+ 0 − 5 + 0 + 3 − 614. a m + 2 − 3a m +1 − 5a m + 20a m − 1 − 25a m − 3 ÷ a 2 − 5 − 5 + 20 + 28 − 23 ⇒ x10 − 5x 6 y 4 + 3x 2 y 8 − 6y10 1 − 3 − 5 + 20 + 0 − 25 1+ 0 − 5 + 5 − 20 − 25 + 5 − 1− 0 + 51− 3 + 0 + 53 − 18 + 9 + 33 − 3 + 0 + 20 ⇒ am − 3am − 1 + 5am − 3 − 3 + 12 + 15 − 3 + 3 + 0 − 15 − 6 + 24 + 30 − 6 + 5 + 0 − 25 + 6 − 24 − 30 + 6 − 5 − 0 + 2515. 7a 2 x + 5 − 35a 2 x + 4 + 6a 2 x + 3 − 78a 2x + 2 − 5a 2 x + 1 − 42a 2 x − 7a 2 x − 1 ÷ 7a x + 3 + 6a x + 1 + a x7 − 35 + 6 − 78 − 5 − 42 − 77 + 0 + 6 +1 −7− 0 −6− 11− 5 + 0 − 7− 35 + 0 − 79 − 5 ⇒ a x + 2 − 5a x + 1 − 7a x − 1+ 35 + 0 + 30 + 5− 49 + 0 − 42 − 7 49 − 0 + 42 + 716. 6x 2a + 3 − 4x 2a + 2 − 28x 2a + 1 + 21x 2a − 46x 2a − 1 + 19x 2a − 2 − 12x 2a − 3 − 6x 2a − 4 ÷ 6x a + 1 − 4x a + 2x a − 1 + x a − 2 6 − 4 − 28 + 21− 46 + 19 − 12 − 66 − 4 + 2 +1 − 6 + 4 − 2 −1 1+ 0 − 5 + 0 − 6− 30 + 20 − 46 + 19⇒ x a + 2 − 5x a − 6x a − 2+ 30 − 20 + 10 + 5− 36 + 24 − 12 − 6 36 − 24 + 12 + 617. 6a 5 x + 3 − 23a 5 x + 2 + 12a 5 x + 1 − 34a 5 x + 22a 5 x − 1 − 15a 5 x − 2 ÷ a 2 x + 2 − 3a 2x + 1 − a 2 x − 5a 2 x − 1 6 − 23 + 12 − 34 + 22 − 151− 3 − 1− 5− 6 + 18 + 6 + 306−5+3− 5 + 18 − 4 + 22 ⇒ 6a 3 x + 1 − 5a 3 x + 3a 3 x − 1+ 5 − 15 − 5 − 253 − 9 − 3 − 15 − 3 + 9 + 3 + 15
• 69. EJERCICIO 593. 9x 3 + 6x 2 + 7 3x 2 7 a 2 + b2− 9x 3 3x + 2 +1. a22.a4 + 2a3 3x 2b2− a4a+2 + 6x 2 − a21+a2a3− 6x 2 b 2 +2 +74. 16a 4 − 20a 3b + 8a 2b 2 + 7ab 3 4a 29. x 3 − x 2 + 3x + 2 x2 − x + 13 − 16a 44a 2 − 5ab + 2b 2 +7b 2x + 2− x3 + x2 − x x+ 24a x − x +1 − 20a 3b+ 2x + 2 + 20a 3b8a 2 b 2 10. x3+ y3x−y − 8a b 2 2 2y 3 − x3 + x2y x 2 + xy + y 2 + x−y + 7ab 3 x2y5. x 2 + 7x + 10 x + 6 − x 2 y + xy 24 xy 2 + y 3 − x 2 − 6x x + 1+ x+6− xy 2 + y 3x + 10 −x − 62y 3 +46. x 2 − 5x + 7 x−411. x5 + y5 x−y3 2y 5 − x + 4x2x − 1+ −x + x y4 4 x 4 + x 3 y + x 2 y 2 + xy 3 + y 4 + x−4x−y −x+7x4 yx−4− x4 y + x3y 2x3y2 +3− x3y2 + x2y37.m4 − 11m2 + 34m2 − 3 x2y3 10− x 2 y 3 + xy 4 − m4 + 3m2 m2 − 8 + 2m −3+ xy 4 + y 5− 8m + 342− xy 4 + y 5 8m − 24 22y 5 + 10 x 2 − 6xy + y 2x +y 12. x + 4 x − 5x + 8x2 − 2x + 13 28.8y 26x + 2 − x 2 − xy x − 7y + − x3 + 2x2 − xx + 6+x+y x2 − 2x + 1− 7xy + y 2 6 x 2 − 6x + 8+ 7xy + 7y2− 6 x 2 + 12 x − 6 + 8y 2 6x + 2
• 70. 14. x − 3x+ 9x 2 + 7 x − 4x 2 − 3x + 25 413. 8a − 6a b + 5ab − 9b 2a − 3b32 23 12b320 x − 10 − 8a 3 + 12a 2b 4a 2 + 3ab + 7b 2 +− x 5 + 3x 4 − 2x 3x 3 − 2x + 3 +2a − 3b x 2 − 3x + 2 6a 2b + 5ab 2− 2x 3 + 9x 2 + 7x − 6a 2b + 9ab 2+ 2x 3 − 6x 2 + 4 x 14ab 2 − 9b 33x 2 + 11x − 4 − 14ab 2 + 21b 3− 3x 2 + 9x − 620x − 1012b 3EJERCICIO 60Para los problemas del 1 al 9 las literales toman los siguentes valores:a = - 1 b = - 2 c = - 1/21. a − 2ab + b2. 3a − 4a b + 3ab − b3. a − 3a + 2ac − 3bc22 32 2343= (− 1) − 2 (− 1) ⋅ 2 + 2 2 = 3 (− 1) − 4 (− 1) ⋅ 2 + 3 (− 1) 2 2 − 2 3 1 1= (− 1) − 3(− 1) + 2 (− 1) − − 3⋅ 2 − 23 2 43 2 2= 1+ 2 ⋅ 2 + 4 = 1+ 4 + 4 = 9 = − 3 − 4 ⋅ 2 − 3⋅ 4 − 8 = − 3 − 8 − 12 − 8 = − 31 11= 1 + 3 + 2 ⋅ + 6⋅ = 1+ 3 + 1+ 3 = 8 224. a − 8a c + 16a c − 20a c + 40ac − c54 3 2 2 345234541 31 21 1 1 = (− 1) − 8 (− 1) − + 16 (− 1) − − 20 (− 1) − + 40 (− 1) − − − 5 2 2 2 2 2111 1 15 5 11 − 32 + 131 = − 1 + 8 ⋅ − 16 ⋅ + 20 ⋅ − 40 ⋅ += − 1+ 4 − 4 + − + = − 1+==−24816 32 2 2 3232 3232 ( ) ( 25. a − b + b − c − a − c ) (2)2() ( 36. b + a − b − c − a − c) ( 3)3 1 2 1 233 = (− 1 − 2) + 2 − − − − 1 − − [ 1 ] 1 = 2 + (− 1) − 2 − − − − 1 − − 23 2 2 2 2 1 212 5 1 2 2 = (− 3) + 2 + − − 1 + = 9 + − − 1 31 3 5 1 3 3[ ]23 2 2= 2 − 1 − 2 + − − 1 + = 13 − − − 2 2 2 2 2 2 25 1 24 125 112431 2 − 31 29 = 9+ − = 9+ = 9 + 6 = 15 = 1− + = 1− = 1− = =− = − 14 2 1 4 4 48 8 82227. ab + ac − bc ( ) ( 28. a + b + c − a − b − c + c) 2cb a2 2 1 1 1 1 11 = − 1+ 2 + − − − 1− 2 − − + − − 1 − 2 − 2 2 2− 1⋅ 2 2 2 2 2 2 = + − = + − −1 1 2 121 1 5 22 1 21 2 2 1 −= 1− − − 3 + − = − − − 22 2 2 2 2 2 211 12 + 1 131 25 1 1 − 25 − 2 = 4 + − 1= 3 + == =341= − − =26 = − = −62 = −62144 44 4 4 2444 ( )(9. 3 2a + b − 4a b + c − 2c a − b ) ( ) [ ] 1 1 1 2 2 2[ 3 62 2] = 3 2 (− 1) + 2 − 4 (− 1) 2 + − − 2 − (− 1 − 2) = 3 − 2 + 2 + 4 2 − + (− 3) = 3⋅ 0 + 4 − = 6 − 3 = 3 2 2
• 71. Para los problemas 10 al 16 las literales toman los siguientes valores:a = 2 b = 1/3 x = - 2 y = - 1 m= 3 n = 1/2 11. (a − x ) + ( x − y ) + ( x − y )(m + x − n) 4 2 210. x − x y + 3xy − y 322 2 282 2[ ] [] [ 2 1 = 2 − (− 2) + − 2 − (− 1) + (− 2) − (− 1) 3 + (− 2) − ] 22 (− 2) − (− 2) (− 1) + 3(− 2)(− 1)24 22 − (− 1) 3 2 = 1 1 816 − 4 − 6 2 2[ ] [] [] = 2 + 2 + − 2 + 1 + 4 − 1 3 − 2 − = [ 4] + − 1 + 3 1 − 2 2 22 2 2[ ] = − ++ 1 = 2 + 2 − 3+ 1 = 2 8 2 2 1 3 34 + 3 37 = 16 + 1 + 3 = 17 + = == 18 2 1 2 2 2 2( ) (12. − x − y + x 2 + y 2 x − y − m + 3b x + y + n)()( )[ = − − 2 − (− 1) + (− 2) + (− 1)][ 22][− 2 − (− 1) − 3]+ 3⋅ 1 − 2 + (− 1) + 2 = − [− 2 + 1]+ [4 + 1][− 5 + 1]+ − 2 − 1 + 2 3 11 1 5 38 + 5 [ ] 225 = 1 + 5 − 4 + − 3 + = 1 − 20 + − = − 19 − = −22 43= − = − 21 2 2 14x x3 1 1 x− y 14.−+ − x + x4 − m13. (3x − 2 y )(2n − 4m) + 4 x y − 2 23y 2 + y 3 n b 2 (− 2) − (− 1) 4 (− 2 ) (− 2) 1 13[ 1 2] = 3(− 2) − 2 (− 1) 2 ⋅ − 4 ⋅ 3 + 4 (− 2) (− 1) − 2 2 2=−+ − (− 2 ) + (− 2 ) − 33 (− 1) 2 + (− 1)34 1 1− 2+1 −1 2 3[ ][= − 6 + 2 1 − 12 + 4 ⋅ 4 ⋅ 1 −] = − 4 − 11 + 16 −[ ]−8 −8 + (2 − 3)(− 2) + 16 − 3 = + 8 + (− 1)(− 2) + 13 2 2 8=− 11 − 3 2−13= 44 + 16 + = 60 + = 60 21 22 888 + 69 77= + 21 + 2 = + 23 === 25 2 315. x ( x − y + m) − ( x − y )( x + y − n) + ( x + y ) (m − 2n) 222 2 233 3 3[ ][ 1 ][]21= (− 2) − 2 − (− 1) + 3 − − 2 − (− 1) (− 2) + (− 1) − + − 2 + (− 1) 32 − 2 ⋅ 22 2 2 2 1 1 9 160 + 9 169= 4 [1 + 1] − [− 2 + 1] 4 + 1 − + [− 2 − 1] (9 − 1) = 4 ⋅ 2 − [− 1] 5 − + [− 3] (8) = 8 + + 9 ⋅ 8 = 80 + = 22 9== 84 21 2 222 22 116. 3a + 2 y + 3n − m + 2 ( x 3 − y 2 + 4) = 3⋅ 2 + 2 (− 1) +3⋅ xm y n−2 3−1 1 ( ) ( ) [ 3 2] 2 − 3 + 2 − 2 3 − − 1 2 + 4 = − 3 − 2 − 3 − 6 + 2 − 8 − 1+ 4[ ] 2 4+ 9114 + 13= − 9−6 [ ] 136 13+ 2 − 5 = − 9 − − 10 = − 19 − = −66 =− 127 6= − 21 1 6EJERCICIO 611. 7 am 8 am9 am 10 am 5. 32a 2 − 3a + 8 ↓↓ ↓ ↓ 2a 2 − 3a + 58a + 5 +5 !+2!−1! −4 !2a 2 − 3a + 82a 2 + 5a + 13 Rta {[ ( ( ))] }3. x 2 − 3xyx2 6. − 3x 2 − − 4 x 2 + 5x − x 2 − x + 63xy − y 2 − x2 + y2 x2 − y2 y 2 Rta= − 3x 2 − { − [4 x + 5x − ( x − x − 6)] } 224. 3x 2 − 5x + 6= − 3x 2 − { − [4 x + 5x − x + x + 6] } 22 − 3x 2 + 8 x − 6 Rta3x= − 3x 2 − {− 3x 2 − 6 x − 6} = − 3x 2 + 3x 2 + 6 x + 6 = 6 x + 6
• 72. ()(7. x + y x − y − x + y ) () 21 3 1 1 311 = x 2 − xy + xy − y 2 − ( x + y )( x + y ) 12.a −ab 2 +ba+ b 4 901523 = x 2 − y 2 − (x 2 + 2 xy + y 2 ) 1 1− a 3 − a 2b 1 2 1 1 a − ab + b 2 4 6 2 3 5 = x 2 − y 2 − x 2 − 2 xy − y 2 1 2 1 = − 2 xy − 2 y 2 −a b−ab 2 6908. a = 2 b = 3 c = 1 1 21 a b + ab 2 1 2 1 a + ab + b 2 c− b692 5 3 (a + b) − 4 (c − b) + −a 1 1 31 2 1 1ab 2 +b− a + ab − b2 1− 31015235 = 3(2 + 3) − 4 (1 − 3) +−21 1 33 +1 4 −ab 2 −b ab = ab −21015 3 3 = 3 ⋅ 5 − 4 (− 2 ) + −2 = 15 + 8 + 1 = 23 + 1 = 2413.− 3ab 2 − b3 a 3 − a 2b + b39. 3x2 − 5y 2 2 x 2 + 5xy + 6 y 2 2a b + 3ab − b 2 23 − 2a 2b + 2b3 − x + 3xy − y22− x − 5xy22a 2b − 2b 3a 3 − 3a 2b + 3b 3 2 x + 3xy − 6 y22 x2 + 6y 2a 3 − 3a 2b + 3b 32 x + 3xy − 6 y 2 2a 2 − ab + b2 x 2+ 6y 2a 5 − 3a 4b + 3a 2b 33x + 3xy 2Rta− a b + 3a b4 3 2− 3ab 4 2 2 11 2+ a b − 3a b 3 22 3+ 3b 510. a − ab + b 32 5 a 5 − 4a 4b + 4a 3b2− 3ab 4 + 3b 5 1 2 3 a + ab − 2b2 2414. x − 5x + 4x 32 1 4 1 31 2 2 a − a b+ ab 3410− 6x 2 − 6 x + 3 2x 3 − 16x 2 + 5x + 121 33 − 8x + 8x − 3 2− x 3 + 19x 2 − 6x + a 3b − a 2b2 +ab 32 8 204 2 x 3 − 19x 2 + 6x x 3 + 3x 2 − x + 12− a 2b 2 + ab 3 − b43 5 1 4 1 3 193 2 2 23 3 2 4 x 3 + 3x 2 − x + 12x2 − x + 3 a + a b− a b +ab − b 34 120 20 5− x 3 + x 2 − 3x x+4x5 − x 3 + 5x 2 4x − 4x + 12 211.− 2x 4 + 2x − 10x 2 − 4x 2 + 4x − 12 + 6x3− 6 x + 30x − 2x + 5x + 7 x − 16x + 3054 32 x 2 − 2x + 6 − x + 2x − 6 x54 3x3 − x + 5 − x + 7 x − 16x(2 + x) (1+ x ) − (x − 2)( x 2 + x − 3) = x 2 (3x + 10) + 2 (3x − 1) 32 22 215. + x 3 − 2x 2 + 6x 5 x 2 − 10x + 30(4 + 4 x + x ) (1+ x ) − (x + x 224 3 − 5x 2 − 2 x + 6) = 3x 3 + 10 x 2 + 6 x − 2 − 5 x 2 + 10x − 30 4 + 5x 2 + 4 x + 4 x 3 − x 3 + 5x 2 + 2 x − 6 = 3x 3 + 10 x 2 + 6 x − 2 3x 3 + 10 x 2 + 6x − 2 = 3x 3 + 10 x 2 + 6 x − 2
• 73. 16. x = − 2 y = 121. [x − (3x + 2)][x + (− x + 3)]2 2= x 2 ( x 2 − 4 x + 4) − (7 x + 6)(x + y) (x − y) + 2 (x + y)(x − y)2 2 [x 2 ][− 3x − 2 x 2 − x + 3 ]= x 4 − 4 x3 + 4 x 2 − 7 x − 6= (− 2 + 1) (− 2 − 1) + 2 (− 2 + 1)(− 2 − 1)22 x 4 − x 3 + 3x 2 − 3x 3 + 3x 2 − 9 x − 2 x 2 + 2 x − 6 = x 4 − 4 x 3 + 4 x 2 − 7 x − 6= (− 1) (− 3) + 2 (− 1)(− 3) x4 − 4x 3 + 4 x2 − 7x − 6 = x4 − 4x 3 + 4 x2 − 7x − 62 2= 1⋅ 9 + 2 ⋅ 3 = 9 + 6 = 15[ 22. x ( x + y ) − x ( x − y ) ][2 (x2] + y 2 ) − 3( x 2 − y 2 )17. x + 2x + 82 = x 2 + xy − x 2 + xy = 2 x + 2 y 2 − 3x 2 + 3 y 2 2x+4 x 2 + 4x + 6= 2 xy= − x 2 + 5y 2x−6 4x − 8x − 3 Rta 2− x 2 + 5y 2 − 2 x 3 y + 10 xy 3 x + 4x + 625x 2 − 4x + 32 xy 4 x 3 y − 7 xy 3Rta18. − {3a + (− b + a ) − 2 (a + b) }[ − 2 (a + b) − (a − b) ]− 2 x y + 10 xy2 x 3 y + 3xy 3 33= − {3a − b + a − 2a − 2b} [ = − 2 a +b− a +b]= − {2a − 3b} − y3 x − y x 2 + 3xy − y 2 3 = − 2 [ 2b ]23. x= − 2 a + 3b = − 4b−x +x y 3 2 x + xy + y 2 2 x 2 + xy + y 2 − 4bx2y x 4 + 3x 3 y − x 2 y 22a − 3b− x y + xy2 2 + x 3 y + 3x 2 y 2 − xy 32 a − 7b Rtaxy 2 + x 2 y 2 + 3xy 3 − y 4[(19. 5x + − 3x − x − y ))]( [ 8 x + − 2 x + (− x + y) ]− xy + y23 x + 4x y + 3x 2 y 2 + 2xy 3 − y 4 Rta43= 5x + [− (3x − x + y )][ = 8x + − 2 x − x + y ]= 5x + [− 2 x − y ]= 8 x − 3x + y ()( 24. x − y x + xy + y − x + y x − xy + y22 2 2 ) ()( )= 5x − 2 x − y = 5x + y= 3x − y [ = x 3 + x 2 y + xy 2 − x 2 y − xy 2 − y 3 − x 3 − x 2 y + xy 2 + x 2 y − xy 2 + y 3]5x + y [ = x3 − y3 − x 3 + y3]3x − y = x3 − y3 − x 3 − y 315x 2 + 3xy= − 2 y3 − 5xy − y 225. a = 4 b = 9 c = 2515x − 2 xy − y + 2 (b − a ) 2 − 3 (c − b) 2 2 Rtaab9bc ca b 1 3 1 2 5 11 2 1 4⋅9 9⋅9 + 2 (9 − 4) − 3 (25 − 9)20.x + x y+xy 2 + y 3 x − xy + y 225 42412 32 4 = 2542 9 1 3 1 2 1 21 1− x + x y − xyx+ y36 815 69 5 4 8 22 3 =+ 2⋅5− 3⋅ 16 ⋅ = + 10 ⋅ − 48 ⋅ 1 2 1 125 163 54 3 x y−xy 2 + y 36 45 12 + 225 − 800 − 563 612 3= + − 80 == = − 56 103 1 2 1 1 5 2 1010 − x y+xy − y 32 612 326. x 3 + 3x 2 − 4x − 12 x + 3 x2 − 4 =x−2[2 x + − 5x − ( x − y )]− 4x +y− x − 3x 3 2 x −4 2? − 4x − 12[] 11= 2 x + − 5x − x + y − x −y 23+ 4x + 12 x2 −4x−2 8+ 13− 1[= 2 x + − 6x + y]− 2x+3y x + 2x2 x+2 Rta 9 22x − 4= 2 x − 6x + y − x+ y Rta 2 3 − 2x + 4= − 4x + y
• 74. { (27. 4 x − 3x − x − (4 + x ) + x − x + (− 3))} [ { }] 28. x + 7x − 52 222 x2 − 9x 4 − 11x 3 + 21x Rta= 4 x2 − {3x − ( x − 4 − x )} + [ x − {x − 3}] Si22 x=−2 x + 7x − 5x 43 218x − 14x − 84 x + 4532= 4 x 2 − {3x − x 2 + 4 + x } + x 2 − x + 3[ ]6 x 2 − 5x − 1− 9x 2 − 63x + 45x 4 + 7 x 3 − 14x 2 − 63x + 45 = 6 (− 2) − 5 (− 2) − 12= 4 x2 − 4 x + x 2 − 4 + x 2 − x + 3 x 4 + 7 x 3 − 14 x 2 − 63x + 45= 6 x − 5x − 12= 6 ( 4) + 10 − 1 = 24 + 10 − 1 = 3330.3[ − x 2 + (− 3x + 4) − (− x + 3) ]x + 5x − 63 2 [ = − x − 3x + 4 + x − 32]29. (a 2 +b 2)(a + b)(a − b)4 [ = a − 3a + 2 (a + 2) − 4 (a + 1) − a + b4 ]x 3 + 5x 2 − 3 [ = − x2 − 2 x + 1] (a 2+b 2 )(a − ab + ab − b ) = a − [3a + 2a + 4 − 4a − 4 − a + b ]22 4 4 = − x2 + 2 x − 1(a + b )(a − b ) = a − [b ]2 22 2 4 4x 3 + 5x 2−3 x2 − x + 2a −a b +a b −b 42 2 2 24 =a −b 4 4x+1− x2 + 2x − 1a −b 4 4 =a −b 4 4x 3 + 5x 2 + x − 2 Rta x +1EJERCICIO 6210.(3a + 8b ) = 9a + 48a b + 64b 3 4 2 63 48( )1. m + 3 = m2 + 6m + 9 211. (4m + 5n ) = 16m + 40m n + 25n 5 6 2 10 5 6122. (5 + x ) = 25 + 10 x + x 12. (7a b + 5x ) = 49a b + 70a b x + 25x4 222 2 34 62 3 4 83. (6a + b) = 36a + 12ab + b13. (4ab + 5xy ) = 16a b + 40ab xy + 25x y2 22 2 3 22 42 3 2 64. (9 + 4m) = 81 + 72m + 16m214. (8x y + 9m ) = 64 x y + 144 x ym + 81m 2 2 3 24 22 3 65. (7 x + 11) = 49 x + 154 x + 1212 215. ( x + 10 y ) = x + 20 x y + 100 y 1012 220 10 12 246. ( x + y ) = x + 2 xy + y2 2216. (a + a ) = a + 2an 2 +a m+ n (1+ 3x2 ) = 1+ 6x2 + 9 x 4 2m 2m 2n7.17. (a + b ) = a + 2a b + bx +1 2 x x +1 2 x +2 () 2x2x8. 2 x + 3 y = 4 x 2 + 12 xy + 9 y 29. (a x + by ) = a x2 2 2 4 2 + 2a 2 xby 2 + b 2 y 4 18. ( x + y ) = x + 2x y + y a +1x −2 2 2a +2 a +1 x − 22 x −4EJERCICIO 63 8. (x − 1) = x − 2 x + 1 2 2 42 ( )1. a − 3 = a 2 − 6a + 9 2 9. ( x − 3ay ) = x − 6ax y + 9a y 5 2 2105 22 42. ( x − 7) = x − 14 x + 49 2 10. (a − b ) = a − 2a b + b2 7 7 2 147 7143. (9 − a ) = 81 − 18a + a 2 24. (2 a − 3b ) = 4a − 12ab + 9b2 22 ( 11. 2m − 3n = 4m2 − 12mn + 9n 2 )25. (4ax − 1) = 16a x − 8ax + 12 22 12. (10x − 9 xy ) = 100x − 180x y + 81x y 35 2 64 52 10 13. ( x − y ) = x − 2 x y + y n 2 (a 3 − b3 ) = a 6 − 2a 3b3 + b62m 2m m n 2n6. 14. (a− 5) = a − 10a + 25 2 (3a− 5b2 ) = 9a 8 − 30a 4b2 + 25b42x −2 2 x −4 x −247. 15. ( x − 3x ) = x a +1− 6x + 9 x a −2 22a + 2 2a −1 2a − 4
• 75. EJERCICIO 64 ( )(11. 1 − 8 xy 8 xy + 1 = 1 − 64 x 2 y 2) ( )( )1. x + y x − y = x 2 − y 2( )( ) 6. n − 1 n + 1 = n 2 − 12. (m − n )(m + n) = m − n 2 2 7. (1 − 3ax )(3ax + 1) = 1 − 9a x 22 12. (6x − m x)(6x + m x) = 36x − m x 2 22 2 4 4 23. (a − x )( x + a ) = a − x22 8. (2m + 9)(2m − 9) = 4m − 812 13. (a + b )(a − b ) = a − b m n mn 2m2n4. (x 2+ a 2 )( x 2 − a 2 ) = x 4 − a 4 9. (a − b )(a + b ) = a − b3 2 3 2 6414. (3x − 5 y )(5 y + 3x ) = 9 x − 25 y a mm a 2a2m ( )(5. 2a − 1 1 + 2a = 4a 2 − 1) 10. ( y − 3 y)( y + 3 y) = y − 9 y2 2 4215.(a x +1 − 2b x −1 )(2b x −1 + a x +1 ) = a 2 x + 2 − 4b2 x − 2EJERCICIO 658. (a − 2a + 3)(a + 2a + 3) = a + 2a + 922 42 ()()1. x + y + z x + y − z = x + 2 xy + y − z22 29. (m − m − 1)(m + m − 1) = m − 3m + 122 422. ( x − y + z)( x + y − z) = x − y + 2 yz − z 2 22( )( )10. 2a − b − c 2a − b + c = 4a 2 − 4ab + b2 − c 23. ( x + y + z)( x − y − z) = x − y − 2 yz − z 2 2211. (2 x + y − z)(2 x − y + z) = 4 x 2 − y 2 + 2 yz − z 24. (m + n + 1)(m + n − 1) = m + 2mn + n − 1225. (m − n − 1)(m − n + 1) = m + n − 2mn − 12 212. (x − 5x + 6)(x + 5x − 6) = x − 25x + 60x − 3622 426. ( x + y − 2)( x − y + 2) = x − y + 4 y − 42 213. (a − ab + b )(a + b + ab ) = a + a b + b22 2 24 2 247. (n + 2n + 1)(n − 2n − 1) = n − 4n − 4n − 1 2 2 42 14. ( x − x − x )( x + x + x ) = x − x − 2 x − x3 23 2 64 3 2EJERCICIO 66 ( )31. a + 2 = a 3 + 6a 2 + 12 a + 8 ( )35. 2 x + 1 = 8 x 3 + 12 x 2 + 6 x + 1( )3 9. 4n + 3 = 64n 3 + 144n 2 + 108n + 276. (1 − 3 y ) = 1 − 9 y + 27 y2. ( x − 1) = x − 3 x + 3x − 1 (a− 2b) = a 6 − 6a 4b + 12a 2b2 − 8b33− 27 y 3 3 3 2 2 23 10.3. (m + 3) = m + 9m + 27m + 27 3 3 27.(2 + y ) = 8 + 12 y2 3 2+ 6y4 + y6 () 3 11. 2 x + 3 y = 8 x 3 + 36 x 2 y + 54 xy 2 + 27 y 34. (n − 4) = n − 12n + 48n − 64 ( )(1− a ) = 1− 3a 33 3 28. 1 − 2n = 1 − 6n + 12n 2 − 8n 32 3 12.2+ 3a 4 − a 6EJERCICIO 67 ( )( )1. a + 1 a + 2 = a 2 + 3a + 2 ()( ) 9. a − 11 a + 10 = a 2 − a − 11017.(a − 2)(a + 7) = a 55 10 + 5a 5 − 142. (x + 2)( x + 4) = x + 6 x + 8 2 10. (n − 19)(n + 10) = n 2− 9n − 190 18. (a + 7)(a − 9) = a 66 12 − 2a 6 − 633. ( x + 5)(x − 2) = x + 3x − 102 11. (a + 5)(a − 9) = a − 4a − 452 2 4 2 ( 19. ab + 5 ab − 6 = a 2b 2 − ab − 30)( )4. (m − 6)(m − 5) = m − 11m + 30 12. ( x − 1)( x − 7) = x − 8 x + 7 (xy − 9)(xy + 12) = x y + 3xy − 108 22 2 4 222 2 4 2 20.5. ( x + 7)( x − 3) = x + 4 x − 21 13. (n − 1)(n + 20) = n + 19n − 2021. (a b − 1)(a b + 7) = a b + 6a b − 7 22 2 42 2 22 2 4 4 2 26. ( x + 2)(x − 1) = x + x − 2 2 14. (n + 3)(n − 6) = n − 3n − 183 3 6 3 22. ( x y − 6)(x y + 8) = x y + 2 x y − 48 3 33 36 63 37. ( x − 3)( x − 1) = x − 4 x + 328. ( x − 5)( x + 4) = x − x − 20 2 15. ( x + 7)( x − 6) = x + x − 423 3 6 3 23. (a − 3)(a + 8) = a + 5a − 24 xx 2xx 16. (a + 8)(a − 1) = a + 7a − 84 4 84 24. (a − 6)(a − 5) = a x +1− 11a + 30x +1 2 x +2 x +1
• 76. EJERCICIO 6820. (x − 2)(x + 5) = x4 48 + 3x 4 − 10( )(21. 1 − a + b b − a − 1 = − 1 + a 2 − 2ab + b 2) ( ) 21. x + 2 = x 2 + 4 x + 42. ( x + 2)( x + 3) = x + 5x + 6222. (a + b )(a − b ) = a − bx n xn 2x2n3. ( x + 1)( x − 1) = x − 1 2 23. ( x − 8)( x + 9) = xa +1 − x − 72 a +12a +2a +14. ( x − 1) = x − 2 x + 1 24. (a b + c )(a b − c ) = a b − c 2 22 2 2 2 22 4 4 45. (n + 3)(n + 5) = n + 8n + 15 ( )2 325. 2a + x= 8a 3 + 12a 2 x + 6ax 2 + x 36. (m − 3)(m + 3) = m − 9(x − 11)(x − 2) = x − 13x + 2222 24 226.7. (a + b − 1)(a + b + 1) = a + 2ab + b −127. (2a − 5b ) = 4a − 20a b + 25b2 23 4 263 488. (1 + b) = 1 + 3b + 3b + b 32 328. (a + 12 )(a − 15 ) = a − 3a − 1803 3 639. (a + 4)(a − 4) = a − 16 2 2429. (m − m + n)(n + m + m ) = m + 2m n + n2242 2 − m210. (3ab − 5x ) = 9a b − 30abx 2 22 2 2+ 25x 430. ( x + 7)( x − 11) = x − 4 x − 774 48 4( )(11. ab + 3 3 − ab = 9 − a 2b 2)12. (1 − 4ax ) 2 = 1 − 8ax + 16a 2 x 2( ) 231. 11 − ab = 121 − 22ab + a 2b213. (a + 8)(a − 7) = a 2 24+ a 2 − 5632.(x y − 8)(x y + 6) = x y − 2 x y − 482 3 2 3 4 62 333. (a + b)(a − b)(a − b ) = a − 2a b + b()()22 4 2 2 414. x + y + 1 x − y − 1 = x 2 − y 2 − 2 y − 115. (1 − a )(a + 1) = 1 − a 234. ( x + 1)( x − 1)( x − 2) = x − 3x + 224216. (m − 8)(m + 12) = m 2+ 4m − 96 35. (a + 3)(a + 9)(a − 3) = a − 812 417. (x − 1)(x + 3) = x + 2 x − 3 2 24 236. ( x + 5)( x − 5)( x + 1) = x − 24 x − 2524 218. ( x + 6)( x − 8) = x − 2 x − 48 3 36 3( )( )( )( )37. a + 1 a − 1 a + 2 a − 2 = a 4 − 5a 2 + 419. (5x + 6m ) = 25x + 60 x m + 36m 4 238. (a + 2)(a − 3)(a − 2)(a + 3) = a − 13a 2 + 36 36 3 48 4a 2 x + 2 − 100EJERCICIO 6914. = a x + 1 + 10a − 4b22 a x + 1 − 107.= a − 2b a + 2b1− 9x 2m + 41. x − 1 = x − 12m+215. 1 + 3x m + 2 = 1− 3x25 − 36x 4 x +1 8.= 5 + 6x 2 1− x 2 5 − 6x 2(x + y ) − z = x + y + z 2 22. 1− x = 1+ x9.4x − 9m n2 = 2x − 3mn2 2 416. (x + y ) − z 2x + 3mn21 − (a + b) 2 x2 − y23. x + y = x − y= 1− a − b1 + (a + b)36m − 49n x 22 417.10.= 6m + 7nx 26m − 7nx 24 − (m + n) 2y2 − x2= y+x 81a 6 − 100b 8 = 2 − m− n2 + (m + n)4.11. 9a 3 + 10b 4 = 9a − 10b 18. 34 y−x x2 − 4 x − (x − y)225. x + = x − 2a 4b6 − 4x 8 y1012. a 2b 3 + x 4 y 5 = a b + 2x y2 34 5=y x + (x − y) 219.2 9 − x46. 3 − x 2 = 3 + x 2x 2n − y 2n= xn − y n(a + x) − 9 = a + x − 3213.xn + yn20.(a + x) + 3
• 77. EJERCICIO 70 EJERCICIO 71 1+ a 31. 1+ a = 1− a + a 2x4 − y4 m5 + n 51.= x 3 + x 2 y + xy 2 + y 3 2.= m4 − m3n + m2n2 − mn3 + n4 x−y m+n 1− a 32. 1− a = 1+ a + a 2a 5 − n53. = a 4 + a 3n + a 2n2 + an3 + n4 a −nx3 + y 33. = x 2 − xy + y 2 x6 − y6 x+y= x 5 − x 4 y + x 3 y 2 − x 2 y 3 + xy 4 − y 54. x+y 8a 3 − 14. 2a − 1 = 4a + 2a + 12a6 − b65.= a 5 + a 4b + a 3b 2 + a 2b 3 + ab 4 + b5 a −b8x 3 + 27y 35. = 4x 2 − 6xy + 9y 2 2x + 3yx7 + y76.= x 6 − x 5 y + x 4 y 2 − x 3 y 3 + x 2 y 4 − xy 5 + y 6 x+y27m3 − 125n36. = 9m2 + 15m + 25n23m − 5n a 7 − m77. = a 6 + a 5m + a 4m2 + a 3m3 + a 2m4 + am5 + m664a + 343 3 a −m7.= 16a 2 − 28a + 494a + 7a 8 − b88. = a7 − a 6b + a 5b 2 − a 4b 3 + a 3b 4 − a 2b 5 + ab6 − b7216 − 125y3a+b8. = 36 + 30y + 25y 26 − 5yx10 − y109.= x 9 + x 8 y + x 7 y 2 + x 6 y 3 + x 5 y 4 + x 4 y 5 + x 3 y 6 + x 2 y 7 + xy 8 + y 9 1 +a b3 3x−y9.= 1− ab + a 2b 21+ abm9 + n910.= m8 − m7n + m6n2 − m5n3 + m4n4 − m3n5 + m2n6 − mn7 + n8 729 − 512b 3 m+n10. = 81+ 72b + 64b 29 − 8b m9 − n911.= m8 + m7n + m6n2 + m5n3 + m4n4 + m3n5 + m2n6 + mn7 + n8 a 3x3 + b3 m−n11. ax + b = a x − axb + b2 22 a10 − x10n3 − m3 x 3 12.= a 9 − a 8 x + a 7 x 2 − a 6 x 3 + a 5 x 4 − a 4 x 5 + a 3 x 6 − a 2 x 7 + ax 8 − x 9 a+x12. n − mx = n + nmx + m x2 2 21− n5 1− a 613. 1− n = 1+ n + n + n + n 14. 1− a = 1+ a + a + a + a + a 2 3 4 2 3 45x 6 − 27y 313. x 2 − y = x + 3x y + 9y4 2 2 31+ a 715. 1+ a = 1− a + a − a + a − a + a 2 3 4 568a 9 + y 914. 2a 3 + y 3 = 4a − 2a y + y 63 361− m81− x1216. 1+ m = 1− m + m − m + m − m + m − m 2 3 4 5 6 715. 1− x 4 = 1+ x + x 48 x 4 − 1627x 6 + 1 17. = x 3 + 2x 2 + 4x + 816. 3x 2 + 1 = 9x − 3x + 1 42x−2 x 6 − 64 64a 3 + b9 18. = x 5 − 2x 4 + 4x 3 − 8x 2 + 16x − 3217. 4a + b3 = 16a − 4ab + b 2 36 x+2 x 7 − 128a 6 − b619.= x 6 + 2x 5 + 4x 4 + 8x 3 + 16x 2 + 32x + 6418. a 2 − b2 = a + a b + b4 2 24x−2 125 − 343 x15 a 5 + 243= 25 + 35x 5 + 49 x10 20.= a 4 − 3a 3 + 9a 2 − 27a + 8119.5 − 7x 5 a+3n +1 4 2 6 x 6 − 72920. n2 + = n − n + 121.= x 5 + 3x 4 + 9x 3 + 27x 2 + 81x + 2431 x−3
• 78. 625 − x 4m8 − 25622.= 125 − 25x + 5x 2 − x 323. = m7 + 2m6 + 4m5 + 8m4 + 16m3 + 32m2 + 64m + 128x+5m−2 x10 − 1 9 8 x 5 + 243y 524. = x + x + x7 + x6 + x5 + x 4 + x3 + x2 + x + 1 25.= x 4 − 3x 3 y + 9x 2 y 2 − 27xy 3 + 81y 4x −1 x + 3y 16a 4 − 81b 426.= 8a 3 + 12a 2b + 18ab 2 + 27b3 2a − 3b 64m6 − 729n627. = 32m5 − 48m4n + 72m3n2 − 108m2n3 + 162mn4 + 243n5 2m + 3n 1. 024x10 − 128.= 512x 9 + 256x 8 + 128x 7 + 64x 6 + 32x 5 + 16x 4 + 8x 3 + 4x 2 + 2x + 1 2x − 1 512a 9 + b929.= 256a 8 − 128a 7b + 64a 6b2 − 32a 5b 3 + 16a 4b 4 − 8a 3b 5 + 4a 2b6 − 2ab7 + b8 2a + b a 6 − 72930.= a 5 + 3a 4 + 9a 3 + 27a 2 + 81a + 243a −3EJERCICIO 72m16 − n16 8. m4 − n4 = m + m n + m n + n 128 4 4 8 12 x6 + y61. x 2 + y 2 = x − x y + y4 2 24 a18 − b18 a 8 − b89.= a15 − a12b 3 + a 9b6 − a 6b9 + a 3b12 − b152. a 2 + b2 = a − a b + a b − b a 3 + b3 6 4 2 2 46x 20 − y 20 m10 − n10 10.= x15 − x10 y 5 + x 5 y10 − y153. m2 − n2 = m + m n + m n + m n + n x5 + y 58 6 2 4 4 2 6 8 m21 + n21 11. m3 + n3 = m − m n + m n − m n + m n − m n + n1815 312 69 9 6 123 1518 a12 − b124. a 3 + b 3 = a − a b + a b − b9 6 3 3 69 x 24 − 1 18 12 6 a12 − x12 12. x 6 − = x + x + x + 15. a 3 − x 3 = a + a x + a x + x9 6 3 3 69 1 a 25 + b 25 13. a 5 + b 5 = a − a b + a b − a b + b2015 510 10 5 15 20 x15 + y156. x 3 + y 3 = x − x y + x y − x y + y129 3 6 6 3 912 m12 + 1a 30 − m307. m4 + = m − m + 1 8 4 14 a 6 − m6 = a + a m + a m + a m + m2418 612 12 6 18 241EJERCICIO 73x4 −1 2x 6 − 27y 31. = x −1= x 4 + 3x 2 y + 9y 21+ x 2 4.x 2 − 3y 8m3 + n6x 6 − 49y 62. 2m + n2 = 4m − 2mn + n 2 24 5.= x 3 − 7y 3x 3 + 7y 3 1 − a5a14 − b143. 1− a = 1+ a + a + a + a2 34 6.= a12 + a10b2 + a 8b 4 + a 6b6 + a 4b8 + a 2b10 + b12a2 − b2
• 79. 1 + a3 64x 6 − 343y 97. 1+ a = 1− a + a 216.= 16x 4 + 28x 2 y 3 + 49y 64x 2 − 7y 316x 2 y 4 − 25m6a18 − b18 = 4xy 2 − 5m317. a 3 + b 3 = a − a b + a b − a b + a b − b 1512 39 6 6 9 3 12158. 4xy 2 + 5m3 x 27 + y 279. x 3 + y 3 = x − x y + x y − x y + x y − x y + x y − x y + y2421 318 615 912 12 9 156 183 21 24a 27 + y 2710. a 9 + y 9 = a − a y + y 189 9 18 (a + x) − y22 =a+ x+ y18. (a + x) − ya 4b 4 − 64x 61+ x11 10 9 8 7 6 5 4 3 211. a 2b2 + x 3 = a b − 8x 2 2 3 819. = x − x + x − x + x − x + x − x + x − x +1 x +11− a 2b 4 c 8 x 40 − y 4012. 1− ab 2c 4 = 1+ ab c2 420. = x 32 + x 24 y 8 + x16 y16 + x 8 y 24 + y 32 x8 − y832x 5 + 243y 513.= 16x 4 − 24x 3 y + 36x 2 y 2 − 54xy 3 + 81y 42x + 3y 25 − (a + 1) 29 − 36x10 = 4− a = 3 − 6x 5 5 + (a + 1)14. 21.3 + 6x 51− x12x 8 − 256 7 = x + 2x 6 + 4x 5 + 8x 4 + 16x 3 + 32x 2 + 64x + 12815. 1− x 4 = 1+ x + x 4822.x−2EJERCICIO 742. x − 3x + 2 x − 2 ÷ x + 1323. x − x + 5 ÷ x − 24 3 = (− 1) − 3 (− 1) + 2 (− 1) − 23 21. x − 2x + 3 ÷ x − 12= 24 − 23 + 5 = 1 − 2 ⋅1+ 3 2 = − 1− 3− 2 − 2 = − 8= 16 − 8 + 5 = 13 = 1− 2 + 3 = 2 6. x + 3x − 2 x + 4 x − 2 x + 2 ÷ x + 35. m + m − m + 5 ÷ m − 44 3 2 54 3 2 = (− 3) + 3(− 3) − 2(− 3) + 4(− 3) − 2(− 3) + 25432 =4 +4 −4 +54 324. a − 5a + 2a − 6 ÷ a + 3432 = 256 + 64 − 16 + 5 = 309 = − 243 + 3⋅ 81 − 2 (− 27) + 4 ⋅ 9 + 6 + 2 = (− 3) − 5 (− 3) + 2 (− 3) − 6 4 32= − 243 + 243 + 54 + 36 + 8 = 988. 6 x + x + 3x + 5 ÷ 2 x + 13 2 = 81 − 5 (− 27) + 2 ⋅ 9 − 6 32 1 1 1 = 81 + 135 + 18 − 6 = 228 = 6 − + − + 3 − + 59. 12x − 21x + 90 ÷ 3x − 33 2 2 2 1 1 3 3 1 3 = 12 ⋅1 3 − 21⋅1+ 907. a − 2a + 2a − 4 ÷ a − 553 = 6 − + − + 5= − + − + 5 8 4 2 4 4 2 = 12 − 21+ 90 = 81= 5 5 − 2⋅5 3 + 2⋅5 − 4 − 3 + 1 − 6 + 20 12 === 3= 3 .125 − 2 ⋅125 + 10 − 444 12. a + a − 8a + 4a + 1 ÷ 2a + 364 2= 3 .125 − 250 + 10 − 4 = 2 . 881 11. 5x 4 − 12 x 3 + 9 x 2 − 22 x + 21 ÷ 5x − 2 3 3 6 34 3 2 = − + − − 8 − + 4 − + 1 24 2 3 2 2 2 2 2 2 2 = 5 − 12 + 9 − 22 + 21 5 5 5 510. 15x − 11x + 10 x + 18 ÷ 3x + 2 729 819 12 3 2 = + − 8⋅ − + 1 3216 84 44 64 164 2 2 2 2 = 5⋅ − 12 ⋅ + 9⋅ −+ 21= 15 − − 11 − + 10 − + 18 62512525 5 729 81729 81 3 3 3 = + − 18 − 6 + 1 =+ − 2316 96 36 44 64 16 64 16 8 4 20 =− +−+ 21= 15 − − 11⋅ − + 18125 125 25 5 729 + 324 − 1. 472 419 27 9 3= = − 80 36 4464 6440 44 20 =− +− + 21=−−−+ 18 125 25 5 993 − 80 + 180 − 1.100 + 2 . 625 1. 625− 40 − 44 − 60 + 162 18= == 13===2 1251259 9
• 80. EJERCICIO 75 11. x 6 − 3x 5 + 4x 4 − 3x 3 − x 2 + 2 ÷ x + 31. x − 7 x + 5 ÷ x − 3 2 6. n4 − 5n3 + 4n − 48 ÷ n + 2 1−3 4 − 3−1 0 2 −31 −5 04 − 48 −2 −318 − 66207 − 618 1. 854 1 −7 5 3− 2 14 − 28 48 1−6 22− 69206 − 618 1. 8563 − 121 − 7 14 − 240 = x 5 − 6x 4 + 22x 3 − 69x 2 + 206x − 618 Re s. 1. 856 1 −4 −7 = n3 − 7n2 + 14n − 24 Re s. 0 = x − 4 Re s. − 712. 2x 3 − 3x 2 + 7x − 5 ÷ 2x − 1 12 −37 − 5 7. x − 3x + 5 ÷ x − 1 4 22. a − 5a + 1÷ a + 2 2 1−1 31 0 0 −3 5 1 1 −5 1 −22 −26−2 1 1 1 −2 − 2 14 = x 2 − x + 3 Re s. − 21 1 1 −2 3 1 − 7 1513. 3a − 4a + 5a + 6 ÷ 3a + 232 = a − 7 Re s. 15= x 3 + x 2 + x − 2 Re s. 3 23 −456 − 3 8. x + x − 12x − x − 4x − 2 ÷ x + 4−2−6 5 4 3 243. x − x + 2x − 2 ÷ x + 13 21 1 − 12 − 1 −4−2−4 3 −690 1 −1 2 − 2−1− 4 12 04 0 = a 2 − 2a + 3 Re s. 0−1 2 − 41 −30 −1 0 −2 1 −24 −6 14. 3x − 4x + 4x − 10x + 8 ÷ 3x − 1432= x 4 − 3x 3 − x Re s. − 21= x − 2x + 4 Re s. − 6 2 3−44− 1083 9. a 5 − 3a 3 + 4a − 6 ÷ a − 21−1 1 −34. x 3 − 2x 2 + x − 2 ÷ x − 21 0 −3 04−62 3−33−95 1 −2 1 −2 22 424 16 = x3 − x2 + x − 3Re s. 5 2 0 21 2 128 10 1 0 1 01515. x − x + 8 x + x − 1 ÷ 2x + 3 6 4 3 2 = a 4 + 2a 3 + a 2 + 2a + 8 Re s. 10= x + 1 Re s. 0 2153 1 0−1 1 0−1−5. a 3 − 3a 2 − 6 ÷ a + 3 x 5 − 208 x 2 + 2076 ÷ x − 5 82 3 915 39 1 −3 0 −6−31 0 0− 208 0 2 . 0765−−0 − 2 4 8 24 − 3 18 − 545 25 125− 415 − 2 . 075 10. 1 3 5 3 5 1 − 6 18 − 605 25 − 83 − 4151 1 −01 − 2 4 2 4= a 2 − 6a + 18 Re s. − 60= x 4 + 5 x 3 + 25x 2 − 83x − 415 Re s. 11 5 3 4 5 3 13 5 = x − x + x + x−Re s. 24 8 2 4 4EJERCICIO 761. x 2 − x − 6 ÷ x − 37. a +1 Es factor de a 3 − 2a 2 + 2a + 5Exacta (6 múltiplo de 3)(− 1)3 − 2(− 1) + 2(− 1) + 522. x + 4x − x − 10 ÷ x + 2 3 2= − 1− 2 − 2 + 5 = 0Exacta (10 múltiplo de 2) No existe residuo, luego a + 1 divide exacta-3. 2x 4 − 5x3 + 7x2 − 9x + 3 ÷ x − 1 mente al polinomio, por lo que se deduce esInexacta (1 no anula el polinomio) un factor de este.4. x 5 + x 4 − 5x 3 − 7x + 8 ÷ x + 38. x − 5 divide a x 5 + 6x 4 + 6x 3 − 5x 2 + 2x − 10Inexacta (8 no es múltiplo de 3)55 + 6 ⋅ 5 4 + 6 ⋅ 53 − 5 ⋅ 52 + 2 ⋅ 5 − 105. 4x 3 − 8x 2 − 11x − 4 ÷ 2x − 1 = 3125 − 3750 + 750 + 125 + 10 − 10 = 0Exacta (4 múltiplo de 1)Al sustituir x por 5 en el polinomio, este se6. 6x 5 + 2x 4 − 3x 3 − x2 + 3x + 3 ÷ 3x + 1anula, entonces x - 5 divide con exactitud aInexacta (- 1 no anula el polinomio)x 5 + 6x 4 + 6x 3 − 5x 2 + 2x − 10
• 81. 9. 4x − 3 divide a 4x4 − 7x 3 + 7x2 − 7x + 3 17. 15n5 + 25n4 − 18n3 − 18n2 + 17n − 11 ÷ 3n + 543 2− 250 30 − 20 5 3 3 3 34 − 7 + 7 − 7 + 3− 18 − 3 −6 4 4 4 415012324 189 63 21 Inexacta; coc. 5n − 6n + 4n − 1; Re s. − 64 2= − + − +3256 64 16 4 18. 7 x − 5 x + k ÷ x − 52324 − 756 + 1. 008 − 1. 344 + 768 0== =0 35150 256 256La variable x del dividendo se reemplaza730 0por 3/4 (4x - 3 = 0 luego x = 3/4) que es elSik = − 150 se anuladivisor.valor de la variable del divisor. Se observasu anulación, por consiguiente, 4x - 3 es19. x 3 − 3x 2 + 4 x + k ÷ x − 2un divisor exacto de tal polinomio. 2−2410. 3n + 2 no es factor de1 −12 0 3n5 + 2n4 − 3n3 − 2n2 + 6n + 7 porque 7 no esk + 4 = 0 , luegok = − 4múltiplo de - 2 / 3, lo cual significa que alreemplazar tal valor en el polinomio re- 20. 2a4+ 25a + k ÷ a + 3sultará un residuo, por ende la división − 6 18 − 54 87no será exacta y 3n + 2 no se puedeconcebir como factor de dicho polinomio.2 − 6 18 − 29 011. 2a 3 − 2a 2 − 4a + 16 ÷ a + 2 Para k = − 87 se cumple que k + 87 = 0− 4 12 − 16 21. 20x − 7 x + 29x + k ÷ 4 x + 13 2 2 −68 0−53 −8Exacta; coc.2a 2 − 6a + 8 20 − 12 320k − 8 = 0 entoces k = 812. a4− a + 2a + 2 ÷ a + 1 2−1 1 0 − 21 −1 0 2 0Exacta; coc. a 3 − a 2 + 2EJERCICIO 7713. x 4+ 5x − 6 ÷ x − 1 x5 + 1 a 5 + 321 1 1 6Inexacta Re s. 641. x − 1 Inexacta Re s. 29.a−21 1 1 60 a 4 + b4Exacta; coc. x 3 + x 2 + x + 62.Inexacta Re s. 2b 4a+b14. x6− 39x 4 + 26x 3 − 52x 2 + 29x − 30 ÷ x − 6x 7 − 128636 − 18 48 − 24 30x8 −110. Inexacta Re s. − 2563. x 2 + Exactax+21 6 −3 8 −4 5 01Exacta; coc. x 5 + 6x 4 − 3x 3 + 8x 2 − 4x + 5 a11 + 14. a − Inexacta Re s. 2115. a − 4a − a + 4a + a − 8a + 25 ÷ a − 4 65 43 2 16a 4 − 81b 44 0 −4 0 4 − 16a 6 + b6 11.Exacta5. 2Inexacta Re s. 2b 62a + 3b1 0 −1 0 1 −4 9a + b2Inexacta; coc. a 5 − a 3 + a − 4 ; Re s. 9 x7 − 16. x − Exacta 1a 3x6 + b916. 16x − 24 x + 37x − 24x + 4 ÷ 4x − 1 43 212. ax 2 + b3 Exacta4−58 −4x3 − 87. x + 2 Inexacta Re s. − 1616− 20 32− 16 0Exacta; coc. 4x 3 − 5x 2 + 8x − 4x 4 − 168.Exacta x+2
• 82. EJERCICIO 781.5x = 8x − 15 2. 4 x + 1= 23.y − 5 = 3y − 254. 5x + 6 = 10x + 5 5.9y − 11= − 10 + 12y 5x − 8x = − 154x = 2 − 1y − 3y = − 25 + 55x − 10x = 5 − 69y − 12y = − 10 + 11− 3x = − 154x = 1− 2y = − 20− 5x = − 1− 3y = 1 − 151− 20−1 1 x= x=y= x=y=−−3 4 −2−53 x=5y = 10 1 x= 56.21− 6x = 27 − 8x 7. 11x + 5x − 1= 65x − 368. 8 x − 4 + 3x = 7 x + x + 14 9. 8x + 9 − 12x = 4x − 13 − 5x − 6x + 8x = 27 − 21 16x = 65x − 36 + 1 11x − 4 = 8 x + 14− 4 x + 9 = − x − 132x = 6 16x − 65x = − 35 11x − 8 x = 14 + 4− 4x + x = − 13 − 96 − 49x = − 353x = 18− 3x = − 22 x=2− 35 18 − 22 x= x=x= x=3 − 493−35x=6 22 x= x=7310. 5y + 6y − 81= 7y + 102 + 65y 11. 16 + 7x − 5 + x = 11x − 3 − x12. 3x + 101− 4 x − 33 = 108 − 16 x − 10011y − 81= 72y + 102 8x + 11= 10x − 3− x + 68 = 8 − 16x11y − 72y = 102 + 818x − 10x = − 3 − 11 − x + 16 x = 8 − 68− 61y = 183− 2x = − 14 15 x = − 60183− 14− 60 y=x=x=− 61−215 y=−3x=7 x=−413. 14 − 12x + 39x − 18x = 256 − 60x − 657x14. 8x − 15x − 30x − 51x = 53x + 31x − 172 9x + 14 = − 717x + 256 − 88x = 84 x − 1729x + 717x = 256 − 14− 88x − 84x = − 172 726x = 242 − 172x = − 172 242 − 172x=x= 726 − 172 1x =1x= 3EJERCICIO 791. x − (2 x + 1) = 8 − (3x + 3)2. 15x − 10 = 6 x − (x + 2) + (− x + 3) 3. (5 − 3x ) − (− 4 x + 6) = (8 x + 11) − (3x − 6)x − 2 x − 1 = 8 − 3x − 3 15x − 10 = 6 x − x − 2 − x + 35 − 3x + 4 x − 6 = 8x + 11 − 3x + 6− x − 1 = 5 − 3x 15x − 10 = 4 x + 1 x − 1 = 5x + 17 − x + 3x = 5 + 115x − 4 x = 10 + 1 x − 5x = 17 + 1 2x = 6 11 − 4 x = 18x=6 1118 x=x=2 x=1 −4 x=3 9 x= − 2
• 83. 4. 30 x − (− x + 6) + (− 5x + 4) = − (5x + 6) + (− 8 + 3x ) 5. 15x + (− 6 x + 5) − 2 − (− x + 3) = − (7 x + 23) − x + (3 − 2 x)30 x + x − 6 − 5x + 4 = − 5x − 6 − 8 + 3x15x − 6 x + 5 − 2 + x − 3 = − 7 x − 23 − x + 3 − 2 x 26 x − 2 = − 2 x − 1410 x = − 10x − 2026 x + 2 x = − 14 + 210 x + 10 x = − 2028x = − 1220 x = − 20 12 − 20 x=− x= 2820 3 x= −1 x=− 7 [ ]6. 3x + − 5x − ( x + 3) = 8 x + (− 5x − 9) [ ] [7. 16 x − 3x − (6 − 9 x ) = 30 x + − (3x + 2) − ( x + 3) ][]3x + − 5x − x − 3 = 8 x − 5x − 9[] 16 x − 3x − 6 + 9 x = 30 x + − 3x − 2 − x − 3 [ ] 3x + [− 6x − 3] = 3x − 9[ ]16 x − 12 x − 6 = 30 x + − 4 x − 5 [ ]3x − 6x − 3 = 3x − 916 x − 12 x + 6 = 30 x − 4 x − 5 − 3x − 3 = 3x − 94 x + 6 = 26 x − 5 − x − 1= x − 3 4 x − 26 x = − 5 − 6 − x − x = − 3+ 1 − 22 x = − 11−2− 11 1 − 2x = − 2 ⇒ x ==1x= =−2 − 22 2 [ { 8. x − 5 + 3x − 5x − (6 + x) = − 3}] {}9. 9 x − (5x + 1) − 2 + 8 x − (7 x − 5) + 9 x = 0 x − [5 + 3x − {5x − 6 − x}] = − 39 x − 5x − 1− {2 + 8 x − 7 x + 5} + 9 x = 0 x − [5 + 3x − {4 x − 6}] = − 34 x − 1− {x + 7} + 9 x = 0 4 x − 1− x − 7 + 9 x = 0[ x − 5 + 3x − 4 x + 6 = − 3 ] 12 x − 8 = 0[] x − 11 − x = − 3 12 x = 8x − 11 + x = − 3 8 2 x = − 3 + 11x=12822x = 8⇒ x ==42x=3[ ][10. 71 + − 5x + (− 2 x + 3) = 25 − − (3x + 4) − (4 x + 3)] { [] }11. − 3x + 8 − − 15 + 6 x − (− 3x + 2) − (5x + 4) − 29 = − 5 [ ] 71 + − 5x − 2 x + 3 = 25 − − 3x − 4 − 4 x − 3[] − {3x + 8 − [− 15 + 6 x + 3x − 2 − 5x − 4] − 29} = − 5[ ] 71 + − 7 x + 3 = 25 − − 7 x − 7[] 71 − 7 x + 3 = 25 + 7 x + 7 − {3x − 21 − [− 21 + 4 x ] } = − 5 74 − 7 x = 32 + 7 x− {3x − 21 + 21 − 4 x} = − 5 74 − 32 = 7 x + 7 x − {− x} = − 542 = 14 xx=−5 42 =xEJERCICIO 80 143= x1. x + 3 ( x − 1) = 6 − 4 (2 x + 3) 2. 5 ( x − 1) + 16 (2 x + 3) = 3 (2 x − 7) − x 3. 2 (3x + 3) − 4 (5x − 3) = x (x − 3) − x (x + 5) x + 3x − 3 = 6 − 8 x − 12 5x − 5 + 32 x + 48 = 6 x − 21 − x 6 x + 6 − 20 x + 12 = x 2 − 3x − x 2 − 5x 4 x − 3 = − 8x − 637 x + 43 = 5x − 21 − 14 x + 18 = − 8 x4 x + 8x = − 6 + 337 x − 5x = − 21 − 43− 14 x + 8 x = − 18 12 x = − 3 32 x = − 64 − 6 x = − 18 −31− 64 − 18x=⇒ x= − x=⇒ x= − 2x= ⇒ x=3 124 32 −6
• 84. 4. 184 − 7 (2 x + 5) = 301 + 6 ( x − 1 ) − 6 ( )() (10. x + 1 2 x + 5 = 2 x + 3 x − 4 + 5 )() 184 − 14 x − 35 = 301 + 6 x − 6 − 6 2 x + 7 x + 5 = 2 x − 5x − 12 + 5 22 149 − 14 x = 289 + 6 x 7 x + 5x = − 7 − 5 149 − 289 = 6 x + 14 x 12 x = − 12 − 140 = 20 x − 12 − 140x= =x 1220x= −1− 7= x5. 7 (18 − x ) − 6 (3 − 5x ) = − (7 x + 9) − 3(2 x + 5) − 1211.(x − 2) − (3 − x)2 2=1126 − 7 x − 18 + 30 x = − 7 x − 9 − 6 x − 15 − 12x2 − 4 x + 4 − 9 + 6x − x2 = 1108 + 23x = − 13x − 36 2x − 5= 1 23x + 13x = − 36 − 1082x = 6 36 x = − 1446 x=− 1442 x=36 x=3 x= − 4 ()( )12. 14 − 5x − 1 2 x + 3 = 17 − 10 x + 1 x − 6 ( )() () ( ) () (6. 3x x − 3 + 5 x + 7 − x x + 1 − 2 x 2 + 7 + 4 = 0) 14 − (10 x2 + 13x − 3) = 17 − (10 x2− 59 x − 6) 3x 2 − 9 x + 5x + 35 − x 2 − x − 2 x 2 − 14 + 4 = 0 14 − 10 x 2 − 13x + 3 = 17 − 10 x 2 + 59 x + 6 − 5x + 25 = 0 − 13x − 59 x = 6− 5x = − 25− 72 x = 6 − 25 x=6−5x= − 72 x=517. − 3(2 x + 7) + (− 5x + 6) − 8 (1− 2 x) − (x − 3) = 0 x= − 12 − 6x − 21 − 5x + 6 − 8 + 16 x − x + 3 = 0 4 x − 20 = 0 13. ( x − 2) 2 + x ( x − 3) = 3( x + 4)( x − 3) − ( x + 2)( x − 1) + 2 4 x = 20 x − 4 x + 4 + x 2 − 3x = 3 ( x 2 + x − 12) − ( x 2 + x − 2) + 2 220 2 x 2 − 7 x + 4 = 3x 2 + 3x − 36 − x 2 − x + 2 + 2x= 4 2 x 2 − 7 x + 4 = 2 x 2 + 2 x − 36 + 4x=5 − 7 x − 2 x = − 368. (3x − 4)(4 x − 3) = (6x − 4)(2 x − 5) − 9 x = − 36 12 x 2 − 9 x − 16 x + 12 = 12 x 2 − 38 x + 20− 36− 25x + 38 x = 20 − 12 x=−913x = 8x= 48 x=14. (3x − 1) − 5( x − 2) − (2 x + 3) − (5x + 2)( x − 1) = 0 22 13 ()( ) (9. 4 − 5x 4 x − 5 = 10 x − 3 7 − 2 x)( ) 9 x 2 − 6x + 1− 5x + 10 − 4 x 2 − 12 x − 9 − 5x 2 + 3x + 2 = 0 − 20 x + 41x − 20 = − 20 x + 76 x − 2122− 20x + 4 = 041x − 76 x = − 21 + 20− 20x = − 4− 35x = − 1−4 x=−1 − 20 x= − 35x=11 5 x= 35
• 85. 2 ( x − 3) − 3 ( x + 1) + ( x − 5)( x − 3) + 4 ( x 2 − 5x + 1) = 4 x 2 − 122 215.2 x 2 − 12 x + 18 − 3x 2 − 6 x − 3 + x 2 − 8x + 15 + 4 x 2 − 20 x + 4 = 4 x 2 − 124 x 2 − 46 x + 34 = 4 x 2 − 12 − 46 x = − 12 − 34 − 46 x = − 46− 46 x=− 46 x=1 7 (x − 4) − 3 (x + 5) = 4( x + 1)(x − 1) − 22 25( x − 2) − 5( x + 3) + (2 x − 1)(5x + 2) − 10 x 2 = 02 219.16.7 x − 56 x + 112 − 3x − 30 x − 75 = 4 x 2 − 4 − 22 25x 2 − 20 x + 20 − 5x 2 − 30 x − 45 + 10 x 2 − x − 2 − 10 x 2 = 04 x 2 − 86 x + 37 = 4 x 2 − 6− 51x − 27 = 0 − 86 x = − 6 − 37− 51x = 27 − 86 x = − 43 27 − 43 x=x=− 51− 861 9 x= x= − 21717. x − 5x + 15 = x ( x − 3) − 14 + 5( x − 2) + 3(13 − 2 x ) 2x 2 − 5x + 15 = x 2 − 3x − 14 + 5x − 10 + 39 − 6 x− 5x + 15 = − 4 x + 15 5 (1 − x ) − 6 ( x 2 − 3x − 7) = x ( x − 3) − 2 x ( x + 5) − 22 20. − 5x + 4 x = 0 5 − 10 x + 5x 2 − 6 x 2 + 18 x + 42 = x 2 − 3x − 2 x 2 − 10 x − 2− x= 0 x= 0 − x 2 + 8 x + 47 = − x 2 − 13x − 28 x + 13x = − 2 − 4718. 3(5x − 6)(3x + 2) − 6 (3x + 4)( x − 1) − 3(9 x + 1)( x − 2) = 021x = − 493(15x 2 − 8 x − 12) − 6 (3x 2 + x − 4) − 3(9 x 2 − 17 x − 2) = 0 − 49x=45x 2 − 24 x − 36 − 18x 2 − 6 x + 24 − 27 x 2 + 51x + 6 = 0 21 21x − 6 = 0 7x= − 21x = 6 3 6x=212x=7EJERCICIO 81[1. 14 x − (3x − 2) − 5x + 2 − ( x − 1) = 0]2. (3x − 7)2[− 5(2 x + 1)( x − 2) = − x 2 − − (3x + 1)][14 x − 3x + 2 − 5x + 2 − x + 1 = 0] 9 x 2 − 42 x + 49 − 5(2 x 2 − 3x − 2) = − x 2 − − 3x − 1[]9 x 2 + x 2 − 42 x + 49 − 10 x 2 + 15x + 10 = 3x + 1[11x + 2 − 4 x + 3 = 0]− 27 x + 59 = 3x + 111x + 2 − 4 x − 3 = 0− 27 x − 3x = 1− 59 7 x − 1= 0 7x = 1 − 30 x = − 58− 5829x=1x=⇒ x=7 − 3015
• 86. {3. 6 x − (2 x + 1) = − − 5x + − (− 2 x − 1) [ ]}8. (x + 2)(x + 3)(x − 1) = (x + 4)( x + 4)(x − 4) + 7 6 x − 2 x − 1 = − − 5x + 2 x + 1 { ]}[ ( x + 5x + 6)(x − 1) = (x + 4)(x − 16) + 7 22 4 x − 1 = − {− 5x + 2 x + 1}x 3 − x 2 + 5x 2 − 5x + 6x − 6 = x 3 − 16 x + 4 x 2 − 64 + 7 4 x − 1 = − {− 3x + 1}4 x 2 + x − 6 = 4 x 2 − 16 x − 57 4 x − 1 = 3x − 1x + 16 x = − 57 + 64 x − 3x = − 1 + 1 17 x = − 51x=0 − 51 x=⇒ x= − 3 () {4. 2 x + 3 − x − 1 = − 3x + 2 x − 1 − 3 x + 2 2 2 ( ) ( )}172 x − 3x2− 3 = − {3x 2 + 2 x − 2 − 3x − 6}9. (x + 1) − (x − 1) = 6x (x − 3)3 32 x − 3x 2− 3 = − {3x 2 − x − 8}x 3 + 3x 2+ 3x + 1 − ( x − 3x + 3x − 1) = 6x − 18x 3 222 x − 3x 2 − 3 = − 3 x 2 + x + 8 x + 3x + 3x + 1 − x + 3x − 3x + 1 = 6x 2 − 18x 3 2 3 2 2x − x = 8 + 3 6 x 2 + 2 = 6 x 2 − 18xx = 112 = − 18 x 21{ [(5. x − 3x + x x + 1 + 4 x − 1 − 4 x222) (]} = 0) − 18 = x⇒ − = x9 x 2 − {3x + [x + x + 4 x − 4 − 4 x ] } = 02223 ( x − 2) ( x + 5) = 3( x + 1) ( x − 1) + 3 2210. x − {3x + [x + x − 4] } = 022 3( x 2 − 4 x + 4)( x + 5) = 3 ( x 2 + 2 x + 1)( x − 1) + 3x 2 − {3x + x 2 + x − 4} = 0 (3x 2 − 12 x + 12)( x + 5) = (3x 2 + 6 x + 3)( x − 1) + 33x + 15x − 12 x 2 − 60 x + 12 x + 60 = 3x 3 − 3x 2 + 6 x 2 − 6 x + 3x − 3 + 3 3 2x 2 − 4 x − x2 + 4 = 03x 2 − 48x + 60 = 3x 2 − 3x− 4x = − 4 − 48x + 3x = − 60−4 − 45x = − 60 x=−4 − 60 4 x=⇒ x= − 45 x=136.3(2 x + 1)(− x + 3) − (2 x + 5) = − − − 3 ( x + 5) + 10 x 2 2[{}] 3(− 2 x + 5x + 3) − 4 x − 20 x − 25 = − − {− 3x − 15} + 10 x 2 22 [ ]EJERCICIO 82− 6 x + 15x + 9 − 4 x − 20 x − 25 = − 3x + 15 + 10 x 22 [ 2 ]− 10 x 2 − 5x − 16 = − 3x − 15 − 10x 21.x → N º mayor − 5x + 3x = 16 − 15x − 8 → N º menor − 2x = 1 x + x − 8 = 1061 2 x − 8 = 106x= −2 x = 106 + 821147. (x + 1)(x + 2)(x − 3) = (x − 2)( x + 1)( x + 1) x= 2 (x + 3x + 2)( x − 3) = ( x − x − 2)(x + 1) 2 2 x = 57 → N º mayor x − 3x + 3x − 9 x + 2 x − 6 = x + x 2 − x 2 − x − 2 x − 23223x − 8 ⇒ 57 − 8− 7 x − 6 = − 3x − 2 = 49 → N º menor− 7 x + 3x = − 2 + 6 − 4x = 4 4x= ⇒ x= −1−4
• 87. 2. x → Nº mayor6. A + B = 1.080 soles10.2x → Nº menor x − 32 → Nº menorA − 1.014 = B2x + 2 → Nº mayor x + x − 32 = 540 A + A − 1.014 = 1.0802x + 2x + 2 = 194 2x = 540 + 32 2A = 1.080 + 1.014 4x = 194 − 2 2x = 5722 .094A= x= 192572 2 4x=A = 1.047 soles 2 x = 48x = 286 → Nº mayor 2x ⇒ 2 ⋅ 48A − 1.014 = B = 96 → Nº menor x − 32 ⇒ 286 − 32⇒ 1.047 − 1.014 = B2x + 2 ⇒ 2 ⋅ 48 + 2= 254 → Nº menor33 soles = B = 96 + 2 7.x → Nº mayor= 98 → Nº mayor3.A + B = 1.154 bs. x − 1→ Nº menor A − 506 = Bx + x − 1= 103 11.x → Nº mayor A + A − 506 = 1.1542x = 103 + 1 x − 1→ Nº medio2A = 1.154 + 506x= 104 x − 2 → Nº menor2A = 1.660 2x = 52 → Nº mayorx + x − 1+ x − 2 = 186 1.660 A=3x − 3 = 1862x − 1⇒ 52 − 13x = 189 A = 830 bs.189 = 51→ Nº menor x= 3 A − 506 = B 8.x → Nº menorx = 63 → Nº mayor ⇒ 830 − 506 = Bx + 1 → Nº medio x − 1⇒ 63 − 1324 bs. = B x + 2 → Nº mayor = 62 → Nº mediox + x + 1+ x + 2 = 204 x − 2 ⇒ 63 − 24. x → Nº mayor3x + 3 = 204 = 61→ Nº menor x − 24 → Nº menor 3x = 204 − 3 x + x − 24 = 106201x= 2x = 106 + 243 130x = 67 → Nº menor x= 2 x = 65 x → Nº mayorx + 1⇒ 67 + 1 12. caballo + coche + arreos = 325 = 68 → Nº medio coche + 80 = caballo x − 24 ⇒ 65 − 24 x + 2 ⇒ 67 + 2 coche − 25 = arreos = 41→ Nº menor= 69 → Nº mayorcoche + 80 + coche + coche − 25 = 325 9.x → Nº 1 x + 1→ Nº 2 3 coches + 55 = 3255. A + B = 56 añosx + 2 → Nº 3 x + 3 → Nº 43 coches = 270 A + 14 = B 270x + x + 1+ x + 2 + x + 3 = 74 coche = A + A + 14 = 563 4x + 6 = 742A = 56 − 14coche = $ 904x = 74 − 642A=68 2x=coche + 80 = caballo 4A = 21años ⇒ 90 + 80 = caballo x = 17 → Nº 1x + 1⇒ 17 + 1 $ 170 = caballo A + 14 = B coche − 25 = arreos = 18 → Nº 221+ 14 = B ⇒ 90 − 25 = arreosx + 2 ⇒ 17 + 2 x + 3 ⇒ 17 + 3 35 años = B$ 65 = arreos = 19 → Nº 3= 20 → Nº 4
• 88. EJERCICIO 8313.x → Nº mayor x → 1º 1.x → edad Juanx − 32 → Nº medio16.x − 20 → 2º3x → edadPedrox − 65 → Nº menor x − 20 − 40 → 3ºx + 3x = 40x + x − 32 + x − 65 = 200⇒ x − 60 → 3º4 x = 40 3x − 97 = 200 3x = 297x + x − 20 + x − 60 = 310 x= 40297 3x = 310 + 80 4x=3x = 390 x = 10 → edad Juan 3 3x ⇒ 3 ⋅10x = 99 → Nº mayorx= 390= 30 → edadPedrox − 32 ⇒ 99 − 323 x = 130 → 1º= 67 → Nº medio 2. x → Arreosx − 65 ⇒ 99 − 65 x − 20 ⇒ 130 − 20 4x → Caballo= 34 → Nº menor = 110 → 2º x + 4x = 600 x − 60 ⇒ 130 − 60 5x = 600 = 70 → 3º600x=514.x → 1º cesto x = $ 120 → Arreosx − 10 → 2º cesto4x ⇒ 4 ⋅120x − 15 → 3º cesto17.x → mayor= $ 480 → Caballox + x − 10 + x − 15 = 575x − 20 → menor x − 18 → medio 3. x → 1º piso 3x − 25 = 575 3x = 600x + x − 20 + x − 18 = 88x → 2º piso 3x − 38 = 882 600x=3x = 88 + 38 x3x + = 48 2x = 200 → 1º cesto3x = 126 2x + xx − 10 ⇒ 200 − 10126 = 48 x= 2 = 190 → 2º cesto 3 3x = 48 ⋅ 2x − 15 ⇒ 200 − 15x = 42 → mayor 3x = 96 x − 20 ⇒ 42 − 20= 185 → 3º cesto96= 22 → menorx= 3 x − 18 ⇒ 42 − 18 x = 32 Habt. → 1º piso= 24 → medio x 3215.x → mayor ⇒ 2 2x − 55 → medio = 16 Habt. → 2º pisox − 70 → menor18.x → mayor4. A + B + C = 300x + x − 55 + x − 70 = 454x − 36 → menorB = 2A 3x − 125 = 454x + x − 36 = 642C = 3A 3x = 454 + 1252x − 36 = 642⇒ A + 2A + 3A = 300 3x = 5792x = 642 + 36 6A = 300579x=2x = 678 300 3 A=x = 193 → mayor6786 x=x − 55 ⇒ 193 − 55 2A = 50 colones x = 339 → mayor B = 2A ⇒ 2 ⋅ 50= 138 → mediox − 70 ⇒ 193 − 70 = 100 colonesx − 36 ⇒ 339 − 36C = 3A ⇒ 3 ⋅ 50= 123 → menor = 303 → menor= 150 colones
• 89. 5. A + B + C = 1338. x → 1º parte13. x → 1º parte B4x → 2º parte A=x → 2º parte 25x → 3º parte 3C = 2Bx + 4x + 5x = 8504xB 10x = 850→ 3º parte ⇒ + B + 2B = 133 32 850x 4xx=x+ += 96B103 3+ 3B = 1332 x = 85 → 1º parte3x + x + 4 xB + 6B= 96= 133 4x ⇒ 4 ⋅ 85 3 2= 340 → 2º parte 8x = 96 ⋅ 37B = 133 ⋅ 2 8x = 2885x ⇒ 5 ⋅ 85266B= = 425 → 3º partex= 288 78B = 38 Sucres x = 36 → 1º parte A= B 38 ⇒ 9. x → Nº buscado x 36 22⇒ = 12 → 2º parte2x = x + 111 3 3 = 19 Sucres 4x 4 ⋅ 362x − x = 111 C = 2B ⇒ 2 ⋅ 38 ⇒ = 4 ⋅12 = 48 → 3º parte x = 111→ Nº buscado3 3= 76 Sucres14. x → EdadEnrique6. x → Nº mayorx → edadRosa 10. 2x → EdadPedro x 3x + 15 → edadMaría → Nº menor3x → Edad Juan 6 x + 3x + 15 = 59x6x → EdadEugeniox + = 147 4x = 59 − 156x + 2x + 3x + 6x = 1324x = 44 6x + x 12x = 132= 14744 6 x=132 7x = 147 ⋅ 6 4x=12 x = 11→ edadRosa 7x = 882x = 11→ EdadEnrique 3x + 15 ⇒ 3 ⋅11+ 15 882 2x ⇒ 2 ⋅11 = 22 → EdadPedrox== 33 + 1573x ⇒ 3 ⋅11 = 33 → Edad Juanx = 126 → Nº mayor= 48 → edadMaría 6x ⇒ 6 ⋅11 = 66 → EdadEugenio x 126 ⇒ 6 6 = 21→ Nº menor11. x → Nº buscado 8 x = x + 21EJERCICIO 847.A + B + C = 1408 x − x = 21 A 7 x = 21x → 1º parte B = ⇒ 2B = A 1. 2213x → 2º parte Cx= B = ⇒ 4B = C7 3x − 40 → 3º parte 4x = 3 → Nº buscado x + 3x + 3x − 40 = 254 2B + B + 4B = 140 7x = 254 + 407B = 140 12. x → Mi edad 7x = 294 140 B= 294 7 3x + 7 = 100x= B = 20 Quetz.3x = 100 − 7 7 x = 42 → 1º parte A = 2B ⇒ 2 ⋅ 203x = 93 3x ⇒ 3 ⋅ 42 = 126 → 2º parte= 40 Quetz. 93 x=3x − 40 ⇒ 3 ⋅ 42 − 40 C = 4B ⇒ 4 ⋅ 20 3 x = 31→ Mi edad = 126 − 40 = 86 → 3º parte= 80 Quetz.
• 90. 5.x → 1º Número 8. A + B + C = 1522. A + B + C = 130x−6B+8C = 2A→ 2º Número B = 2 A − 8⇒ =A5 2 B − 15 = C ⇒ B − 15 = 2A x − 6 → 3º Número B − 32 = C B = 2A + 15x−6 B+8 A + 2A + 15 + 2A = 130 x+ + x − 6 = 72+ B + B − 32 = 1525 2 5A = 130 − 15x 6B 82x + − = 78 + + 2 B = 152 + 32 5A = 115 5 52 2115 10x + x6B + 4B A== 78 += 184 − 45 55 2 A = 23 Balb.11x 390 + 6 5B = 180 ⋅ 2 = B = 2A + 15 ⇒ 2 ⋅ 23 + 15 = 46 + 15 = 61Balb. 5 5360 11x = 396B= C = 2A ⇒ 2 ⋅ 23 = 46 Balb. 5 396B = $ 72x=3.x → 1º Número 11 B + 8 72 + 8 80x = 36 → 1º NúmeroA= ⇒ == $ 40 x−8 22 2→ 2º Número 2x−636 − 6 C = B − 32 ⇒ 72 − 32 = $ 40 ⇒ x − 18 → 3º Número 5 5 x−8=30= 6 → 2º Número x++ x − 18 = 238 2 5x 8 x − 6 ⇒ 36 − 6 = 30 → 3º Número2x + − = 2562 24x + x6. A + B = 99 = 256 + 4 9. x → Nº buscado2B = 3A + 19 x − 80 = 220 − 2 x 5x = 260 ⋅ 2 A + 3A + 19 = 99 x + 2x = 220 + 80 520 4A = 99 − 193x = 300 x= 5 4A = 80 300 x = 104 → 1º Número 80x= A=3 x − 8 104 − 8 96 4⇒ = = 48 → 2º Número x = 100 → Nº buscado 222 A = 20 bs. x − 18 ⇒ 104 − 18 = 86 → 3º Número B = 3A + 19 ⇒ 3 ⋅ 20 + 19 = 60 + 19 = 79 bs.4.x → Costo trajex7. x → cm de azúl10. x → Tengo ahora→ Costo sombrero8 x − 14 2x + 10 = x + 60→ cm deblanco x − 30 → Costo bastón 2 2x − x = 60 − 10 x x − 14x = 50 S /. → Tengo ahora x + + x − 30 = 259x+= 74 82 xx 142x + = 259 + 30 x+ −= 74 82 211. x → Parte separada 16x + x 2x + x x + 80 → La otra parte= 289= 74 + 78 2 x + x + 80 = 910 17x = 289 ⋅ 83x = 81⋅ 2 2x = 910 − 802 .312162x=x=830173 x=2x = $ 136 → Costo traje x = 54 → cmde azúl x = 415 cm x 136x − 14 54 − 14⇒ 4 ,15 m → Parte separada ⇒= $ 17 → Costo sombrero ⇒ 8 8 22x + 80 ⇒ 415 + 80 = 495 cm x − 30 ⇒ 136 − 30 = $ 106 → Costo bastón = 40= 20 → cmde blanco ⇒ 4 , 95 m → La otra parte2
• 91. 12.x → Edad padre14. x → Nº buscado x−313. A + B + C = 9 . 000 8 x − 60 = 60 − 7 x → Edad hijo 3 B + 500 = A 8 x + 7 x = 60 + 60x−3B − 800 = C15 x = 120x+= 83 3B + 500 + B + B − 800 = 9 . 000 120 x 3x= x + − = 83 3B = 9 .000 + 30015 3 3 9 . 300x = 8 → Nº buscado 3x + xB== 83 + 1 3 3 B = 3 .100 Votos15. x → Edad hom bre 4x = 84 ⋅ 3 2x − 17 = 100 − xA = B + 500 ⇒ 3 .100 + 500 = 3 . 600 Votos 2522x + x = 100 + 17x=C = B − 800 ⇒ 3 .100 − 800 = 2 . 300 Votos43x = 117x = 63 → Edad padre 117x= x − 3 63 − 3 603 ⇒== 20 → Edad hijo 3 3 3x = 39 → Edad hom breEJERCICIO 853. x → Partemayor 6.x → Nº mayor x − 232 → Partemenorx − 88 → Nº menor1. x → Nº mayorx + x − 232 = 1.08032x = 1.080 + 232x − 882x x+ = 540 → Nº menor 1.31233 x= x 88 2x2x+ −= 540 x+= 100x = 656 → Partemayor 3 33 3x + x88 x − 232 ⇒ 656 − 232 = 540 +3x + 2x= 424 → Partemenor 3 3 = 100 4 x 1. 620 + 88 3 = 5x = 100 ⋅ 3 4. A + B = 150 3 3 A − 46 = B4 x = 1. 708300 x=A + A − 46 = 150x= 1.708 5 42A = 150 + 46 x = 60 → Nº mayor x = 427 → Nº mayor 1962x 2 ⋅ 60A=x − 88 427 − 88 ⇒ = 40 → Nº menor 2⇒33 A = 98 Soles 33339 B = A − 46 ⇒ 98 − 46 = = 113 → Nº menor2. x → Edad padre3= 52 Soles x − 15→ Edad hijo x → Ang. mayor x → N º mayor 25. 7. x + 45 x − 12x − 15→ Ang. menor→ N º menorx+ = 60 2 42x + 45 x − 12 x 15 x+= 180 x− = 36 x+ −= 602 4 2 2 x 45 x 122x + x15 x+ + = 180x− += 36 = 60 +2 24 42 22x + x 454x − x = 180 − = 36 − 33x 120 + 15 2 2 4= 3x 360 − 45 22=3x = 33⋅ 4 3x = 13522 3x = 132 3x = 315135 132x=315x=3x=3 3x = 44 → N º mayor x = 45 → Edad padre x = 105 ! → Ang. mayor x − 12 44 − 12 x − 15 45 − 15x + 45 105 + 45⇒= 8 → N º menor⇒= 15 → Edad hijo⇒= 75! → Ang. menor44 2 22 2
• 92. 8 x → Costo perro9. A + B = 8410.x → Nº Señoritas x A − 16 = B + 20x − 15 → Costo collar → Nº Jovenes 8⇒ A − 16 − 20 = B 2xx − 15x + = 54 A − 36 = B x+ = 608 2A + A − 36 = 84 8x + xx15= 54 2A = 84 + 36 x + = 60 + 822 9x = 54 ⋅ 8 120 A=2 x + x 120 + 15 2 = 9x = 432 22 A = $ 60 4323x = 135x=B = A − 36 ⇒ 60 − 36 = $ 24 9 135 x= x = $ 48 → Costo perro 3 x 48x = 45 → Nº Señoritas ⇒= $ 6 → Costo collar 12.x → Nº mayor 8 8x − 1545 − 15⇒= 15 → Nº jovenesx + 150 22 → Nº menor 3x → Parte mayorx → Esti log ráfica11. x + 150 13.x + 16x+ = 506x − 10 → Lapicero→ Parte menor33 x + x − 10 = 18x + 16 x150x+= 160x + = 506 − 2x = 28 3 3 328x 163x + x 1.518 − 150x= x + = 160 −=233 3 3x = 14 bs. → Esti log ráfica3x + x 480 − 164x = 1.368= x − 10 ⇒ 14 − 10 = 4 bs. → Lapicero3 31. 3684x = 464x= 4464 14. x → Parte rojax=x = 342 → Nº mayor 4x + 4 → Parte negrax = 116 → Parte mayor x + 150 342 + 150 ⇒x + x + 4 = 84x + 16116 + 16 33⇒ 2x = 803 3492 = = 164 → Nº menor x = 40 cm → Parte roja1323== 44 → Parte menor x + 4 ⇒ 40 + 4 = 44 cm → Parte negra 3EJERCICIO 863. 2x → Tiene A 5. x → Nº var onesx → TieneB x→ Nº Srtas1. 2 x → Edad actual A 2x − 30 = x − 5 3 x → Edad actual B2x − x = 30 − 5 x+ 14 = x − 102 x − 10 = 3 ( x − 10) x = $ 25 → TieneB3 x2 x − 10 = 3x − 30 2x ⇒ 2 ⋅ 25 = $ 50 → Tiene A− x = − 10 − 14 3 2 x − 3x = − 30 + 10x4. → Tiene A x − 3x − x = − 202 = − 24 x → Tiene B3 x = 20 → Edad actual B − 2x = − 72 + 66 = 2 ( x − 90) x 2 x ⇒ 2 ⋅ 20 = 40 → Edad actual A 2 x = 36 → Nº var ones x + 132 = 2 ( x − 90) x 36 ⇒ = 12 → Nº Srtas2. 2 3x → Edad A 33 x + 132 = 4 (x − 90)x → Edad B x + 132 = 4 x − 3606. 3x → Edad padre3x + 5 = 2 ( x + 5) − 3x = − 492x → Edad hijo3x + 5 = 2 x + 10 − 492 x=3x − 5 = 2 ( x + 10) −3 3x − 2 x = 10 − 5 3x − 5 = 2 x + 20 x = 164 colones → Tiene Bx = 5 → Edad B x = 25→ Edad hijo x 164 3x ⇒ 3⋅ 5 = 15 → Edad A ⇒ = 82 → colones Tiene A3x ⇒ 3⋅ 25 = 75 → Edad padre 2 2
• 93. 8. 5x → Tiene Enrique9.x → Bolsa 17. x → Nº mayorx → Tiene suhno.x − 400 → Bolsa 2 2x − 56 → Nº menor 5x − 0 ,5 = x + 0 , 5x + x − 400 = 1. 400 x + 2x − 56 = 855x − x = 0 , 5 + 0 , 52x = 1. 8003x = 1414x = 1x = 900 S /. → Bolsa 1 1411 x − 400 ⇒ 900 − 400 = 500 S /. → Bolsa 2 x= x=3 4 x = 47 → Nº mayorx = $ 0 , 25 → Tiene suhno 2x − 56 ⇒ 2 ⋅ 47 − 565x ⇒ 5 ⋅ 0 , 2512. 3x → Edad actual Juan = 94 − 56 = 38 → Nº menor= $ 1, 25 → Tiene Enrique x → Edad actual hijo 3x + 22 = 2 ( x + 22) 11. 2 x → Edad act . padre3x = 2 x + 44 − 2210. 4x → Días Trab.Pedrox → Edad act . hijox = 22 → Edad actual hijo x → Días Trab.Enrique2 x − 14 = 3( x − 14)3x ⇒ 3⋅ 22 = 66 → Edad actual Juan4x − 15 = x + 212 x − 14 = 3x − 4213. A + B = 84 ⇒ A = 84 − B 4x − x = 21+ 152 x − 3x = − 42 + 14A + 80 = 3 ( B + 4)3x = 36 − x = − 28 ⇒ 84 − B + 80 = 3B + 12x= 36x = 28 → Edad act . hijo − B − 3B = 12 − 1643 Edades hace 14 años :− 4 B = − 152x = 12 → Días Trab.Enrique2 x − 14 ⇒ 2 ⋅ 28 − 14 − 152B=4x ⇒ 4 ⋅12 = 42 años → padre−4= 48 → Días Trab.Pedrox − 14 ⇒ 28 − 14 B = $ 38 A = 84 − B ⇒ 84 − 38 = $ 46= 14 años → hijoEJERCICIO 871. 2x → Nº Sombreros3. 16 − x → Pr ob. reslt . 5. 35 − x → Trajes de 30 Qx → Nº trajes x → Pr ob. no reslt .x → Trajes de 25 Q 4x + 50x = 70212 (16 − x) − 5x = 7330 (35 − x ) + 25x = 1.01554x = 702 192 − 12 x − 5x = 731. 050 − 30 x + 25x = 1.015 x= 702− 17 x = 73 − 192− 5x = 1.015 − 1.05054 − 119 − 35 x = 13 → Nº trajes x=x=− 17−5 2x ⇒ 2 ⋅13 x = 7 → Trajes de 25 Qx = 7 → Pr ob. no reslt .= 26 → Nº Sombreros 35 − x ⇒ 35 − 7 = 28 → Trajes de 30 Q 16 − x ⇒ 16 − 7 = 9 → Pr ob. reslt . 6. x → Traje Cal.2. x → Cab. x − 7 → Traje inf.4. 50 − x → Días trab. x − 6 → Vacas32 x + 18 ( x − 7) = 1.624x → Días no trab.600x + 800 ( x − 6) = 40 .000 32 x + 18x − 126 = 1. 624 3(50 − x) − 2 x = 90 600 x + 800 x − 4 .800 = 40 .00050x = 1.750 150 − 3x − 2 x = 90 1. 400x = 44 .8001.750 − 5x = − 60x=44 .80050 x=− 60 x = 35balb. → Traje Cal. 1. 400 x=−5x − 7 ⇒ 35 − 7 = 28balb. → Traje inf. x = 32 → Cab.x = 12 → Días no trab. x − 6 ⇒ 32 − 6 = 26 → Vacas 50 − x ⇒ 50 − 12 = 38 → Días trab.
• 94. 8. 3 x + 5 → Sac. Frij. 9. 80 − x → Cedro 10. 1. 050 − x → P. mayor x → Sac. azúc.x → Caobax → P. menor7. 3x → N º Lápicesx → N º cuad .6 (3 x + 5) + 5 x = 582 0 , 75 (80 − x ) + 0 , 90 x = 68 , 40 (1. 050 − x ) − 2 x = 1. 8253 0 , 05 ⋅ 3x + 0 , 06 x = 1 , 47 18 x + 30 + 5x = 58260 − 0 , 75x + 0 , 90 x = 68 , 40 .150 − 3x − 2 x = 1.8253 0 ,15x + 0 , 06 x = 1 , 4723 x = 552 0 ,15x = 8 , 40− 5x = 1.825 − 3.150 0 , 21x = 1, 47 552 8 , 40− 5x = − 1. 325 x= x= − 1. 325 1 , 47 23 0 , 15 x=x= x = 24 −5 0 , 21 x = 56x=7 ⇒ 24 → Sac. azúc. x = 265⇒ 56 pies → Caoba 3 ⇒ 7 → N º cuad . 3 x + 5 ⇒ 3 ⋅ 24 + 5⇒ 265 → P. menor80 − x ⇒ 80 − 56 = 77 → Sac. Frij.1. 050 − x ⇒ 1. 050 − 265 3x → 3 ⋅ 7 = 21→ N º Lápices = 24 pies3 → Cedro= 785 → P. mayorEJERCICI0 88 4. x → Costo casa 7. x → Gastéx → 1ºx x1. = + 2 . 00085 − x = 4x 2x → 2º4 6 85 = 5xx x + 12 . 000x + 2x − 20 → 3º = 854 6=x⇒ 3x − 20 → 3º56x = 4x + 48 . 000x + 2x + 3x − 20 = 196 17 = x2x = 48 . 0006x = 196 + 20 ⇒ $ 17 → Gasté48 .000216 x=x=2 6x = 24 . 000bs. → Costo casax = 36 → 1º x → Nº mayor x → Edad act . B2x ⇒ 2 ⋅ 36 = 72 → 2º5.8.2 ( x − 12) → Edad A hace 12 años2 x − 1563x − 20 ⇒ 3 ⋅ 36 − 20 → Nº menor3 = 108 − 20 = 88 → 3º2 x − 1562 ( x − 12) + 24 + 68 = 3 ( x + 12)x+= 108 32 x − 24 + 92 = 3x + 362x 156 x+ = 108 +2 x − 3x = 36 − 682. 3x → Edad A3 3x → Edad B3x + 2x 324 + 156− x = − 32 = x = 32 → Edad act . B 3x − 5 = 4 ( x − 5)33 5x = 480 Edad actual de A : 3x − 5 = 4 x − 202 ( x − 12) + 12 ⇒ 2 (32 − 12) + 12 480x= 3x − 4 x = − 20 + 55x = 96 → Nº mayor= 2 ⋅ 20 + 12 = 52 años− x = − 152 x − 1562 ⋅ 96 − 156 x = 15 → Edad B⇒33 3x ⇒ 3⋅ 15 = 45 → Edad A 36== 12 → Nº menor 3 9. x → mon. 10 cts.3.x → Par zap.22 − x → mon. 5 cts.6. x → Ancho 2 x + 50 → Traje 461− 11= 9x 0 , 10 x + 0 , 05 (22 − x ) = 1 , 8550 (2 x + 50) + 35x = 16 . 000 0 , 10 x + 1 ,10 − 0 , 05x = 1, 85450 = 9x 100 x + 2.500 + 35x = 16 .0004500 , 05x = 1, 85 − 1 ,10135x = 16 .000 − 2. 500=x 9 0 , 05x = 0 , 75 13. 500 50 = x 0 , 75 x=x= 135 ⇒ 50 pies → Ancho0 , 05 x = 100 soles → Par zap. x = 15 → mon.10 cts. 2 x + 50 ⇒ 2 ⋅ 100 + 50 = 250 soles → Traje 22 − x ⇒ 22 − 15 = 7 → mon. 5 cts.
• 95. x → Parte hijox → Lunes10. x → N º buscado15.19. x + 2 . 000 → Parte hijas 2 x → Martes12 ( x − 24) = 24 ( x − 27)3x + 2 (x + 2 . 000) = 16 .5004 x → Miercoles 12 x − 288 = 24 x − 648 3x + 2 x + 4 . 000 = 16 .5008 x → Jueves 12 x − 24 x = − 648 + 288 5x = 12 . 5008 x − 30 → Viernes − 12 x = − 360 12 .500 8 x − 20 → Sábadox= x + 2 x + 4 x + 8 x + 8 x − 30 + 8 x − 20 = 911− 3605 x= x = 2 .50031x − 50 = 911 − 12 ⇒ 2 .500 colones → Parte hijo 31x = 911 + 50 x = 30 → N º buscadox + 2 .000 ⇒ 2 .500 + 2 . 000 = 4 .500961 x=11. x → c / cab. ⇒ 4 .500 colones → Parte hijas 31 x = $ 31→ Lunes35x = 40 ( x − 10) x → N º mayor 16. x − 1→ N º menor 2 x ⇒ 2 ⋅ 31 = $ 62 → Martes35x = 40 x − 4004 x ⇒ 4 ⋅ 31 = $ 124 → Miercoles− 5x = − 400 ( ) 2x − x − 1 = 3128 x ⇒ 8 ⋅ 31 = $ 248 → Jueves x − x + 2 x − 1 = 312 2 − 4008 x − 30 ⇒ 8 ⋅ 31 − 30 = $ 218 → Viernesx=2 x = 32−58 x − 20 ⇒ 8 ⋅ 31 − 20 = $ 228 → Sábado x = 16 → N º mayorx = $ 80 → c / cab. x − 1⇒ 16 − 1 = 15→ N º menor20.x → Nº 112. x → Nº buscado 17. 3x → Edad Ax − 18 → Nº 23x − 55 = 233 − x x → Edad Bx + x − 18 = 3 ⋅18 3x + x = 233 + 55x→ Edad C2x = 54 + 1854x = 288 72 x − 12 → Edad C x=288 2 x=Luego : 4xx = 36 → Nº 1 x = 72 → Nº buscado= x − 12 5x − 18 ⇒ 36 − 18 = 18 → Nº 2 x → N º menorx = 5 ( x − 12)x → Tiene A13. 21.x = 5x − 60x + 1→ N º medio3( x − 16) → Tiene B − 4 x = − 60x + 2 → N º mayorx = 15 → Edad B x + 3 ( x − 16) = 362 x + 3( x + 1) + 4 ( x + 2) = 740 3 x ⇒ 3 ⋅ 15 = 45 → Edad A x + 3x − 48 = 362 x + 3x + 3 + 4 x + 8 = 740x − 12 ⇒ 15 − 12 = 3 → Edad C4 x = 84 9 x = 740 − 1118. x → Edad act . A 84 729 x+5 x= x=4→ Edad B en 5 años9 3 x = $ 21→ Tiene A x = 81 x + 20 → Edad B en 20 años 3( x − 16) ⇒ 3 (21 − 16)⇒ 81 → N º menor2 = 3⋅ 5 = $15 → Tiene Bx + 1⇒ 81 + 1 = 82 → N º medioLuego :x + 2 ⇒ 81 + 2 = 83 → N º mayor x+5x + 20 22. 3x → Tiene A + 15 =3 2x → Tiene B14. x → A caballo x + 5 + 45 x + 20=x → Tiene C3x → Enauto 3 22x − 20 → A pie2 ( x + 50) = 3( x + 20)x x + 3x + x − 20 = 150 3x − 1 − ( x − 3) = 2 + 20 2 x + 100 = 3x + 602 5x = 150 + 20− x = − 403x − 1 − x + 3 = x + 40170x = 40 → Edad act . Ax= 2 x − x = 40 − 25 Edad actual de B : x = 38 → Tiene Bx = 34 Km → A caballox + 2040 + 20 3x ⇒ 3⋅ 38 = $ 114 → Tiene A3x ⇒ 3 ⋅ 34 = 102 Km → Enauto− 20 ⇒− 2022x 38x − 20 ⇒ 34 − 20 = 14 Km → A pie= 30 − 20 = 10 años⇒= $19 → Tiene C2 2
• 96. 23. x → Costo tienda 27. 4 x → Cab. 30. 2 x → L arg oxx x → Vacasx → Ancho − 800 =5x − 4 . 000 x 7 4 x + 5 = 3 (x + 5)(2 x − 6)(x + 4) = 2 x 2 = 5 7 4 x + 5 = 3x + 15 2 x 2 + 2 x − 24 = 2 x 27 x − 28 .000 = 5 xx = 10 → Vacas2 x = 242 x = 28 .000 4 x ⇒ 4 ⋅ 10 = 40 → Cab. x = 12 m → Ancho x = 14 . 0002 x ⇒ 2 ⋅ 12 = 24m → L arg o⇒ 14 . 000 bs. → Costo tienda 28x → Lunes24. x → Cab. peor 31. 3x → Padre hace 5 años x + 6 → Martes2 ( x + 15) → Cab. mejor x → Hijo hace 5 añosx + 12 → Miercolesx + 2 ( x + 15) = 120x + 18 → Jueves 3x + 10 = 2 ( x + 10)x + 2 x + 30 = 1203x + 10 = 2 x + 204x → Jueves3x = 90 x = 10 añosx + 18 = 4xx = $ 30 → Cab. peor− 3x = − 18 Edad actual Padre :2 ( x + 15) = 2 (30 + 15) x = $ 6 → Lunes3x + 5 ⇒ 3⋅ 10 + 5 = 35 años= 2 ⋅ 45 = $ 90 → Cab. mejorx + 6 ⇒ 6 + 6 = $ 12 → Martes Edad actual Hijo :25. x → queda A3x → queda Bx + 12 ⇒ 6 + 12 = 18 → Miercolesx + 5 ⇒ 10 + 5 = 15 añosx + 3x = 1604x ⇒ 4 ⋅ 6 = $ 24 → Jueves32. 3x → Edad A en 4 años 4x = 160 x → Edad B en 4 años x = 40 29. x → Tenía ppio.3x − 6 = 5 ( x − 6) 2 x − 50 + 2 (2 x − 50) − 390 = 0Como A tenía 80 Q.⇒ lo que perdío A 3x − 6 = 5x − 30= 80 − x ⇒ 80 − 40 = 40 Q. 2 x − 440 + 4 x − 100 = 0 − 2 x = − 2426. 2 x → Emp. A 6 x = 540 x = 12 añosx → Emp. B 540Edad Actual A : x=2 (2 x − 400) = x + 400 6 3x − 4 ⇒ 3⋅ 12 − 4 = 32 años4 x − 800 = x + 400x = 90Edad Actual B :3x = 1. 200⇒ 90 soles → Tenía ppio.x − 4 ⇒ 12 − 4 = 8 años x = $ 400 → Emp. B2 x ⇒ 2 ⋅ 400 = $ 800 → Emp. AEJERCICIO 8920. 2a x + 2ax − 3ax2 21. a + ab = a a + b2 ( )11. 9a 3 x 2 − 18ax 3 = 9ax 2 (a 2 − 2 x )= ax (2a + 2 x − 3) ( )2. b + b 2 = b 1 + b12. 15c d + 60c d = 15c d 32 2 3 2 2(c + 4d )21. x 3 + x 5 − x 7 = x 3 (1 + x 2 − x 4 )3. x + x = x ( x + 1)2 13. 35m2 n3 − 70m3 = 35m2 (n3 − 2m) 22. 14 x 2 y 2 − 28 x 3 + 56 x 44. 3a − a = a (3a − 1)3 2214. abc + abc2 = abc 1 + c( )= 14 x 2 ( y 2 − 2 x + 4 x 2 )5. x − 4 x = x (1 − 4 x )3 43 (2a − 3xy )15. 24a 2 xy 2 − 36x 2 y 4 = 12 xy 22 2 23. 34ax 2 + 51a 2 y − 68ay 26. 5m + 15m = 5m (1 + 3m)= 17a (2 x 2 + 3ay − 4 y 2 )16. a + a + a = a (a + a + 1)2 32 32 27. ab − bc = b (a − c)17. 4 x − 8 x + 2 = 2 (2 x − 4 x + 1) 2224. 96 − 48mn 2 + 144n 38. x y + x z = x ( y + z)2 22 = 48 (2 − mn 2 + 3n 3 )18. 15 y + 20 y − 5 y = 5 y (3 y + 4 y − 1) 32 29. 2a x + 6ax = 2ax (a + 3x )22 25. a 2b 2 c 2 − a 2 c 2 x 2 + a 2 c 2 y 210. 8m − 12mn = 4m (2m − 3n) 19. a − a x + ax = a (a − ax + x )= a 2 c 2 (b 2 − x 2 + y 2 )232 2 2 2
• 97. 26. 55m2 n 3 x + 110m2 n 3 x 2 − 220m2 y 334. 12 m2 n + 24m3n 2 − 36m4 n 3 + 48m5n 4= 55m2 (n 3 x + 2n 3 x 2 − 4 y 3 ) = 12m2 n (1 + 2mn − 3m2 n 2 + 4m3n 3 )27. 93a 3 x 2 y − 62a 2 x 3 y 2 − 124a 2 x35. 100a 2b 3c − 150ab 2 c 2 + 50ab 3c 3 − 200abc2= 31a x (3axy − 2 x y − 4) 22 2 = 50abc (2ab 2 − 3bc + b 2 c 2 − 4c)x − x + x − x = x (1 − x + x − x)x5 − x 4 + x 3 − x 2 + x = x (x 4 − x 3 + x 2 − x + 1) 23 4 2 328.36.29. a − 3a + 8a − 4a = a (a − 3a + 8a − 4)6 4 3 2 2 4 237. a − 2a + 3a − 4a + 6a 2345 630. 25x − 10 x + 15x − 5x = a 2 (1 − 2a + 3a 2 − 4a 3 + 6a 4 ) 75 3 2= 5x (5x − 2 x + 3x − 1) 25 338. 3a 2 b + 6ab − 5a 3b 2 + 8a 2bx + 4ab2 mx − x + 2 x − 3x = x ( x − x + 2 x − 3)15 12 9 6 6 9 6 3 = ab (3a + 6 − 5a 2b + 8ax + 4bm)31.32. 9a 2 − 12ab + 15a 3b 2 − 24ab 339. a − a + a − a + a − a 2016128 42= 3a (3a − 4b + 5a 2b 2 − 8b 3 ) = a 2 (a 18 − a 14 + a 10 − a 6 + a 2 − 1)33. 16 x 3 y 2 − 8 x 2 y − 24 x 4 y 2 − 40 x 2 y 3= 8 x 2 y (2 xy − 1 − 3x 2 y − 5y 2 )EJERCICIO 901. a ( x + 1) + b ( x + 1) = ( x + 1)(a + b)19. (x + 2)(m − n) + 2 (m − n) = (m − n)(x + 4) 22 ( ) ( ) ( )( )2. x a + 1 − 3 a + 1 = a + 1 x − 3( ) ( )( ) ()(20. a x − 1 − a + 2 x − 1 = x − 1 a − a − 2 = − 2 x − 1 ) ( )3. 2 ( x − 1) + y ( x − 1) = ( x − 1)(2 + y )21. 5x (a 2 + 1) + (x + 1) (a 2 + 1) = (a 2 + 1)(6x + 1)4. m (a − b) + (a − b) n = (a − b)(m + n)22. (a + b)(a − b) − (a − b)(a − b )5. 2 x (n − 1) − 3 y (n − 1) = (n − 1)(2 x − 3 y )= (a − b)(a + b − a + b) = 2b (a − b )6. a (n + 2) + n + 2 = (n + 2)(a + 1)7. x (a + 1) − a − 1 = (a + 1)( x − 1)( )() (23. m + n a − 2 + m − n a − 2 = 2m a − 2 )()( )24. ( x + m)( x + 1) − ( x + 1)( x − n)8. a 2 + 1− b (a 2 + 1) = (a 2 + 1)(1 − b)= ( x + 1)( x + m − x + n) = ( x + 1)(m + n)()) ( )((9. 3x x − 2 − 2 y x − 2 = x − 2 3x − 2 y)25. ( x − 3)( x − 4) + ( x − 3)( x + 4) = ( x − 3) 2 x10. 1 − x + 2a (1 − x ) = (1 − x )(1 + 2a )11. 4 x (m − n) + n − m = (m − n)(4 x − 1)26. (a + b − 1)(a + 1) − a22 − 1 = (a 2 + 1)(a + b − 2)12. − m − n + x (m + n) = (m + n)(x − 1)27. (a + b − c)( x − 3) − (b − c − a )( x − 3)13. a (a − b + 1) − b (a − b + 1) = (a − b + 1)(a − b3 2 3 2) = ( x − 3)(a + b − c + a − b + c) = ( x − 3) 2a14. 4m (a 2 + x − 1) + 3n ( x − 1 + a 2 ) = (a 2 + x − 1)(4m + 3n)()( ) () ( )(28. 3x x − 1 − 2 y x − 1 + z x − 1 = x − 1 3x − 2 y + z)29. a (n + 1) − b (n + 1) − n − 1 = (n + 1)(a − b − 1)15. x (2a + b + c) − 2a − b − c= x (2a + b + c) − (2a + b + c) = (2a + b + c)( x − 1)30. x (a + 2) − a − 2 + 3 (a + 2) = (a + 2)(x + 2)16. ( x + y )(n + 1) − 3 (n + 1) = (n + 1)( x + y − 3)31. (1 + 3a )( x + 1) − 2a ( x + 1) + 3 ( x + 1) = ( x + 1)(a + 4)17. ( x + 1)( x − 2) + 3 y ( x − 2) = ( x − 2)( x + 1 + 3 y ) ( )() (32. 3x + 2 x + y − z − 3x + 2 − x + y − 1 3x + 2 ) ( )( )18.(a + 3)(a + 1) − 4 (a + 1) = (a + 1)(a + 3 − 4) = (a + 1)(a − 1) = (3x + 2)( x + y − z − 1 − x − y + 1) = − z (3x + 2)
• 98. EJERCICIO 9117. n x − 5a y − n y + 5a x22 22 2 2 9. 3abx − 2 y − 2 x + 3aby22221. a 2 + ab + ax + bx= (3abx 2 + 3aby 2 ) − (2 y 2 + 2 x 2 )= (n 2 x − n 2 y 2 ) − (5a 2 y 2 − 5a 2 x ) = (a 2 + ab) + (ax + bx ) = 3ab (x 2 + y 2 ) − 2 (x 2 + y 2 )= n 2 ( x − y 2 ) − 5a 2 ( y 2 − x ) = a (a + b) + x (a + b) = (x 2 + y 2 )(3ab − 2)= n 2 ( x − y 2 ) + 5a 2 (x − y 2 ) = (a + b)(a + x )= ( x − y 2 )(n 2 + 5a 2 ) 10. 3a − b + 2b x − 6ax 222. am − bm + an − bn= (3a − 6ax) − (b 2 − 2b 2 x) 18. 1 + a + 3ab + 3b = (am − bm) + (an − bn)= (1 + a ) + (3ab + 3b)= 3a (1 − 2 x ) − b 2 (1 − 2 x ) = m (a − b) + n (a − b)= (1 + a ) + 3b (a + 1)= (1 − 2 x )(3a − b 2 ) = (a − b)(m + n) = (1 + a )(3b + 1) 11. 4a x − 4a b + 3bm − 3amx 323. ax − 2bx − 2ay + 4by 19. 4am − 12amn − m + 3n3 2 = (ax − 2bx ) − (2ay − 4by ) = (4a 3 x − 4a 2b ) + (3bm − 3amx )= (4am3 − 12amn) − (m2 − 3n) = x (a − 2b) − 2 y (a − 2b)= 4a 2 (ax − b) + 3m (b − ax )= 4am (m2 − 3n) − (m2 − 3n) = (a − 2b)( x − 2 y )= 4a 2 (ax − b) − 3m (ax − b)= (m2 − 3n)(4am − 1)= (ax − b)(4a 2 − 3m)4. a x − 3bx + a y − 3by 2 2 222 220. 20ax − 5bx − 2by + 8ay = (a 2 x 2 − 3bx 2 ) + (a 2 y 2 − 3by 2 ) 12. 6ax + 3a + 1 + 2 x= (20ax + 8ay) − (5bx + 2by )= (6ax + 3a ) + (1 + 2 x ) = x 2 (a 2 − 3b) + y 2 (a 2 − 3b)= 4a (5x + 2 y ) − b (5x + 2 y)= 3a (2 x + 1) + (2 x + 1) = (a 2 − 3b)( x 2 + y 2 )= (5x + 2 y )(4a − b)= (2 x + 1) (3a + 1)5. 3m − 2n − 2nx 4 + 3mx 421. 3 − x 2 + 2abx 2 − 6ab 13. 3x − 9ax − x + 3a 3 2 = (3m + 3mx 4 ) − (2n + 2nx 4 )= (3 − x 2 ) + (2abx 2 − 6ab)= (3x 3 − x ) − (9ax 2 − 3a ) = 3m (1 + x 4 ) − 2n (1 + x 4 )= (3 − x 2 ) + 2ab (x 2 − 3)= x (3x 2 − 1) − 3a (3x 2 − 1) = (1 + x 4 )(3m − 2n)= (3 − x 2 ) − 2ab (3 − x 2 )= (3x 2 − 1)( x − 3a )= (3 − x 2 )(1 − 2ab)6. x − a + x − a x2 2 2 14. 2a x − 5a y + 15by − 6bx22 = − (a 2 + a 2 x) + ( x 2 + x )= (2a 2 x − 5a 2 y ) + (15by − 6bx)22. a + a + a + 1 3 2 = − a 2 (1 + x) + x ( x + 1) = (a 3 + a 2 ) + (a + 1)= a 2 (2 x − 5 y ) + 3b (5 y − 2 x ) = ( x + 1)( x − a 2 )= a 2 (a + 1) + (a + 1)= a 2 (2 x − 5 y) − 3b (2 x − 5 y )= (a 2 + 1)(a + 1)7. 4 a 3 − 1 − a 2 + 4a = (2 x − 5 y )(a 2 − 3b) = (4a 3 + 4a ) − (1 + a 2 ) 15. 2 x 2 y + 2 xz 2 + y 2 z 2 + xy 323. 3a 2 − 7b 2 x + 3ax − 7ab 2= (3a 2 + 3ax ) − (7b 2 x + 7ab 2 ) = 4a (a 2 + 1) − (1 + a 2 )= (2 x 2 y + xy 3 ) + (2 xz 2 + y 2 z 2 )= 3a (a + x ) − 7b 2 ( x + a ) = (a 2 + 1)(4a − 1)= xy (2 x + y 2 ) + z 2 (2 x + y 2 )= (a + x )(3a − 7b 2 )= (2 x + y 2 )( xy + z 2 )8. x + x − xy − y 22224. 2am − 2an + 2a − m + n − 1 = ( x + x 2 ) − ( xy 2 + y 2 )16. 6m − 9n + 21nx − 14mx= (2am − 2an + 2a ) − (m − n + 1)= (6m − 14mx ) − (9n − 21nx ) = x (1 + x ) − y 2 ( x + 1)= 2a (m − n + 1) − (m − n + 1)= 2m (3 − 7 x ) − 3n (3 − 7 x ) = ( x + 1)( x − y 2 )= (2a − 1)(m − n + 1)= (3 − 7 x )(2m − 3n)
• 99. 25. 3ax − 2by − 2bx − 6a + 3ay + 4b28. 2 x 3 − nx 2 + 2 xz 2 − nz 2 − 3ny 2 + 6 xy 2 = (3ax − 6a + 3ay ) − (2by + 2bx − 4b) = − (nx 2 + nz 2 + 3ny 2 ) + (2 x 3 + 2 xz 2 + 6 xy 2 ) = 3a ( x − 2 + y ) − 2b ( y + x − 2)= − n ( x 2 + z 2 + 3 y 2 ) + 2 x (x 2 + z 2 + 3 y 2 ) = ( x + y − 2)(3a − 2b )= (2 x − n)(x 2 + 3 y 2 + z 2 )26. a 3 + a + a 2 + 1 + x 2 + a 2 x 229. 3x 3 + 2axy + 2ay 2 − 3xy 2 − 2ax 2 − 3x 2 y = (a 3 + a 2 + a 2 x 2 ) + (a + 1 + x 2 )= (3x 3 − 3xy 2 − 3x 2 y ) + (2axy + 2ay 2 − 2ax 2 ) = a 2 (a + 1 + x 2 ) + (a + 1 + x 2 )= 3x ( x 2 − y 2 − xy) + 2a ( xy + y 2 − x 2 ) = (a 2 + 1) (a + 1 + x 2 ) = 3x ( x 2 − y 2 − xy) − 2a (− xy − y 2 + x 2 )= (3x − 2a )( x 2 − xy − y 2 )27. 3a − 3a b + 9ab − a + ab − 3b3 2 22 2 30 a b − n + a b x − n x − 3a b x + 3n x 2 3 4 2 3 24 2 2 34 = (3a − 3a b + 9ab ) − (a − ab + 3b3222 2 ) = (a 2b3 + a 2b 3 x 2 − 3a 2b3 x ) − (n4 + n 4 x 2 − 3n 4 x) = 3a (a − ab + 3b ) − (a − ab + 3b2 22 2 ) = a 2b3 (1 + x 2 − 3x) − n 4 (1 + x 2 − 3x ) = (3a − 1)(a − ab + 3b2 2 ) = (a 2b3 − n 4 )(1 + x 2 − 3x)EJERCICIO 92 n2 n 2 17. 49m6 − 70am3n 2 + 25a 2 n 428. + 2mn + 9m2 = + 3m31. a 2 − 2ab + b2 = a − b( )29 = (7m3 − 5an2 ) 22. a 2 + 2ab + b = (a + b)22) ( )29. a + 2a a + b + a + b 2 ( 2 18. 100 x 10 − 60a 4 x 5 y 6 + 9a 8 y12= (a + a + b) = (2a + b) 2 2 − 2 x + 1 = ( x − 1)23. x 2 = (10 x − 3a y )4 6 230. 4 − 4 (1 − a ) + (1 − a) 5 2 y + 2 y + 1 = ( y + 1) 4222 19. 121 + 198 x 6 + 81x 12 = (11 + 9 x 6 )4.= (2 − 1 + a ) = (1 + a)22 25. a 2 − 10a + 25 = a − 5( )231. 4m − 4m (n − m) + (n − m) 20. a − 24am x + 144m x 2 2 2 4 4226. 9 − 6x + x 2 = 3 − x ( ) 2 = (a − 12m2 x 2 )= (2m − n + m) = (3m − n)2 2 2 16 + 40 x + 25x = (4 + 5x24 2 2 ) 21. 16 − 104 x + 169 x = (4 − 13x ) 32. (m − n) + 6 (m − n) + 97. 2 42 228. 1 − 14a + 49a = 1 − 7a 2 ( ) 2 22. 400 x 10 + 40 x 5 + 1 = (20 x 5 + 1) = (m − n + 3) 2 29. 36 + 12m2 + m4 = (6 + m 2 2 )33. (a + x ) − 2 (a + x )( x + y ) + ( x + y ) 2 2 2 a 2 a − ab + b = − b1 − 2a 3 + a 6 = (1 − a ) 2 23.10. 3 2 42 = (a + x − x − y ) = (a − y ) 2 2 a 8 + 18a 4 + 81 = (a 4 + 9) 2 2b b2 b 34. (m + n) − 2 (a − m)(m + n) + (a − m) 2 2 211.24. 1 + + = 1+ 3 9 3= (m + n − a + m) = (2m + n − a) a 6 − 2a 3b3 + b6 = (a 3 − b3 ) 2 2 2212.b4 2 b2 25. a − a b + = a − ( ) ( )( ) ( )4 2 22 235. 4 1 + a − 4 1 + a b − 1 + b − 113. 4 x 2 − 12 xy + 9 y 2 = 2 x − 3 y( ) 2 4 2= (2 + 2a − b + 1) = (2a − b + 3) 2 2 9b − 30a b + 25a = (3b − 5a ) 22 24 2 2 1 x 2 25x 4 1 5x 2 14.− += −36. 9 ( x − y ) + 12 ( x − y )( x + y ) + 4( x + y ) 26.36 5 6 2 2 25 31 + 14 x y + 49 x y = (1 + 7 x y) 2= (3x − 3 y + 2 x + 2 y ) = (5x − y )24 2 215.222 y4 3 y2 27. 16 x − 2 x y += 4x − 6 3 216. 1 − 2a + a = (1 − a5 10 5 2)16 4
• 100. EJERCICIO 93x 2 y 2 z 4 x yz 2 x yz 2 (1. x 2 − y 2 = x + y x − y)( ) 27. − = + − 100 81 10 9 10 9 ( )( )2. a 2 − 1 = a + 1 a − 1 x 6 4a 10 x 3 2a 5 x 3 2a 5 ( )( )3. a 2 − 4 = a + 2 a − 2 28.− = + − 49 121 7 11 7 11 4. 9 − b = (3 + b )(3 − b) 21 8 1 1 5. 1 − 4m = (1 + 2m)(1 − 2m) 29. 100m n − x = 10mn 2 + x 4 10mn 2 − x 4 2 4 2 16 4 4 6. 16 − n = (4 + n)(4 − n) (a+ b n )(a n − b n ) 2 30. a 2n − b 2n =n7. a − 25 = (a + 5)(a − 5)2 1 n 1 n 18. 1 − y = (1 + y )(1 − y )2 31. 4 x −2n= 2x + 2x − 9 3 39. 4a − 9 = (2a + 3)(2a − 3)2 a 4 n − 225b 4 = (a 2 n + 15b 2 )(a 2 n − 15b 2 )25 − 36 x 4 = (5 + 6 x 2 )(5 − 6 x 2 ) 32.10. y 2 n 3m y n 3m y n 11. 1 − 49a 2b 2 = 1 + 7ab 1 − 7ab()() 33. 16 x6m −= 4x + 4x − 49 7 712. 4 x 2 − 81y 4 = (2 x + 9 y 2 )(2 x − 9 y 2 ) b12 x 5n b 6 x 5n b 6 x a 2b8 − c 2 = (ab 4 + c)(ab 4 − c) 34. 49a −= 7a + 7a − 10 n13.81 9 9 14. 100 − x 2 y 6 = (10 + xy 3 )(10 − xy 3 ) 1 n 2 n 1 n 2 n 1 35. a b − = a b + a b − 2n 4n15. a − 49b = (a + 7b10 125 6)(a − 7b ) 5 6 25 5 516. 25x y − 121 = (5xy2 42 + 11 )(5xy − 11)2 36.1 1 1 − x 2n = + x n − x n 100 10 1017. 100m2 n 4 − 169 y 6= (10mn 2 + 13 y 3 )(10mn 2 − 13 y 3 )18. a 2 m4 n 6 − 144 = (am2 n 3 + 12)(am2 n 3 − 12)EJERCICIO 9419. 196 x 2 y 4 − 225z12= (14 xy 2 + 15z 6 )(14 xy 2 − 15z 6 )() 2 1. x + y − a 2 = x + y + a x + y − a ())(20. 256a12 − 289b 4 m10 2. 4 − (a + 1) = (2 + a + 1)(2 − a − 1) = (3 + a )(1 − a) 2= (16a 6 + 17b 2 m5 )(16a 6 − 17b 2 m5 ) 3. 9 − (m + n) = (3 + m + n)(3 − m − n ) 221.1 − 9ab c d = (1 + 3ab c d 2 4 682 3 4)(1− 3ab c d ) 2 3 4 4. (m − n) − 16 = (m − n + 4)(m − n − 4) 222. 361x14 − 1 = (19 x 7 + 1)(19 x 7 − 1)5. ( x − y) − 4 z = ( x − y + 2 z)(x − y − 2 z) 22111 6. (a + 2b) − 1 = (a + 2b + 1)(a + 2b − 1) 223. − 9a 2 = + 3a − 3a422 7. 1 − ( x − 2 y ) = (1 + x − 2 y )(1 − x + 2 y )2a2 a a 24. 1 − = 1+ 1− 25 5 5 8. ( x + 2a ) − 4 x 2 2 1 4x 1 2x 1 2x = ( x + 2a + 2 x)( x + 2a − 2 x ) = (3x + 2a )(2a − x ) 225. − = + − 16 49 4 7 4 7 ( ) ( ) = (a + b + c + d )(a + b − c − d ) 9. a + b − c + d 22a2 x6 a x3 a x3 − = + − 10. (a − b) − (c − d ) = (a − b + c − d )(a − b − c + d ) 2226.36 25 6 5 6 5
• 101. 11. ( x + 1) − 16 x 225. (2a + b − c) − (a + b)2 2 2= ( x + 1 + 4 x)( x + 1− 4 x) = (5x + 1)(1 − 3x) = (2a + b − c + a + b )(2a + b − c − a − b) = (3a + 2b − c)(a − c)12. 64m2 − (m − 2n)2= (8m + m − 2n)(8m − m + 2n) = (9m − 2n)(7m + 2n) ( ) ( 2 26. 100 − x − y + z = 10 + x − y + z 10 − x + y − z )( )( ) ( ) ()( )− ( y − x ) = (x + y − x )( x − y + x ) = ( y )(2 x − y )2 2 213. a − 2b − x + y = a − 2b + x + y a − 2b − x − y 27. x 214. (2a − c) − (a + c) 28. (2 x + 3) − (5x − 1)2 22 2= (2a − c + a + c)(2a − c − a − c) = ( 3a ) (a − 2c) = (2 x + 3 + 5x − 1)(2 x + 3 − 5x + 1) = (7 x + 2)(4 − 3x )15. ( x + 1) − 4 x 29. ( x − y + z ) − ( y − z + 2 x )2 222= ( x + 1 + 2 x )( x + 1 − 2 x ) = (3x + 1)(1 − x )= ( x − y + z + y − z + 2 x )(x − y + z − y + z − 2 x ) = (3x ) (2 z − 2 y − x )16. 36 x 2 − (a + 3x )2= (6x + a + 3x)(6 x − a − 3x ) = (9 x + a )(3x − a ) 30. (2 x + 1) − ( x + 4)2 2a 6 − (a − 1) = (a 3 + a − 1)(a 3 − a + 1) = (2 x + 1 + x + 4)(2 x + 1− x − 4) = (3x + 5)( x − 3)217.18. (a − 1) − (m − 2)31. (a + 2 x + 1) − ( x + a − 1)2 2 2 2= (a − 1 + m − 2)(a − 1 − m + 2) = (a + m − 3)(a − m + 1)= (a + 2 x + 1 + x + a − 1)(a + 2 x + 1 − x − a + 1) = (2a + 3x )( x + 2)19. (2 x − 3) − (x − 5)2 2= (2 x − 3 + x − 5)(2 x − 3 − x + 5) = (3x − 8)( x + 2)() 2( 32. 4 x + a − 49 y 2 = 2 x + 2a + 7 y 2 x + 2a − 7 y )( )() ( )() 33. 25 ( x − y ) − 4 ( x + y )2 2 220. 1 − 5a + 2 x = 1 + 5a + 2 x 1 − 5a − 2 x = (5x − 5 y + 2 x + 2 y )(5x − 5 y − 2 x − 2 y )21. (7 x + y ) − 81 = (7 x + y + 9)(7 x + y − 9)2 = (7 x − 3 y )(3x − 7 y )m6 − (m2 − 1) = (m3 + m2 − 1)(m3 − m2 + 1)222. 34. 36 (m + n) − 121(m − n)2 216a − (2a + 3) = (4a + 2a + 3)(4a − 2a − 3)2 = (6m + 6n + 11m − 11n)(6m + 6n − 11m + 11n) 10 2 525223.( ) (224. x − y − c + d ) = (x − y + c + d )(x − y − c − d )2 = (17m − 5n)(17n − 5m)EJERCICIO 9510. 4 x + 25 y − 36 + 20 xy 22 7. a + 4 − 4a − 9b 224. a − 2a + 1− b221. a + 2ab + b − x2 22= (a − 2) − 9b 2= (2 x + 5 y ) − 36 2= (a − 1) − b 2 2 = (a + b ) − x 222= (a + 3b − 2)(a − 3b − 2)= (2 x + 5 y + 6)(2 x + 5 y − 6) = (a + b + x )(a + b − x ) = (a − 1 + b)(a − 1 − b) 8. x + 4 y − 4 xy − 1 2 211. 9 x 2 − 1 + 16a 2 − 24ax5. n + 6n + 9 − c2 22. x − 2 xy + y − m22 2= (x − 2 y ) − 1= (3x − 4a ) − 12= (n + 3) − c2 2 = (x − y) − m 22 2= ( x − 2 y + 1)( x − 2 y − 1)= (3x − 4a + 1)(3x − 4a − 1) = ( x − y + m)( x − y − m) = (n + 3 + c)(n + 3 − c)12. 1 + 64a b − x − 16ab 2 2 4 9. a − 6ay + 9 y − 4 x 2 226. a + x + 2ax − 42 23. m + 2mn + n − 12 2= (a + x ) − 4= (a − 3 y ) − 4 x 2= (8ab − 1) − x 4 22 2 = (m + n) − 12= (a + x + 2)(a + x − 2)= (a − 3 y + 2 x)(a − 3 y − 2 x)= (8ab − 1 + x 2 )(8ab − 1 − x 2 ) = (m + n + 1)(m + n − 1)
• 102. 21. 9 x − a − 4m + 4am 30. 9 x + 4 y − a − 12 xy − 25b − 10ab2 22 2 22213. a − b − 2bc − c 2 22 = 9 x 2 − (a 2 − 4am + 4m2 ) = (9 x − 12 xy + 4 y ) − (a + 10ab + 25b 2 )2 22= a 2 − (b 2 + 2bc + c 2 ) = 9 x 2 − (a − 2m)= (3x − 2 y ) − (a + 5b) 2 2 2= a 2 − (b + c) 2 = (3x + a − 2m)(3x − a + 2m)= (3x − 2 y + a + 5b)(3x − 2 y − a − 5b)= (a + b + c)(a − b − c)31. 2 am − x − 9 + a + m − 6 x2 2 2 22. 16 x y + 12ab − 4a − 9b 2 2 2 214. 1 − a + 2ax − x= (a 2 + 2am + m2 ) − ( x 2 + 6 x + 9) 22 = 16x 2 y 2 − (4a 2 − 12ab + 9b 2 )= 1 − (a − 2ax + x 2 2 ) = (a + m) − ( x + 3) 2 2 = 16x 2 y 2 − (2a − 3b)2= 1 − (a − x ) = (a + m + x + 3)(a + m − x − 3) 2 = (4 xy + 2a − 3b)(4 xy − 2a + 3b)= (1 + a − x)(1 − a + x ) 32. x − 9a + 6a b + 1 + 2 x − b 2422 23. − a + 25m − 1 − 2a2 2 = ( x 2 + 2 x + 1) − (b 2 − 6a 2b + 9a 4 )15. m − x − 2 xy − y = 25m2 − (a 2 + 2a + 1) 2 2 2= m2 − ( x 2 + 2 xy + y 2 )= ( x + 1) − (b − 3a 2 ) 2 2 = 25m2 − (a + 1)2= m2 − ( x + y)= ( x + 1 + b − 3a 2 )( x + 1 − b + 3a 2 ) 2 = (5m + a + 1)(5m − a − 1)= (m + x + y)(m − x − y ) 33. 16a − 1 − 10m + 9 x − 24ax − 25m 2 2 2 24. 49 x − 25x − 9 y + 30 xy 4 2 2 = (16a 2 − 24ax + 9 x 2 ) − (25m2 + 10m + 1)16. c − a + 2a − 1 = 49 x 4 − (25x 2 − 30 xy + 9 y 2 ) 2 2 = (4a − 3x) − (5m + 1) 2 2= c2 − (a 2 − 2a + 1) = 49 x 4 − (5x − 3 y )2 = (4a − 3x + 5m + 1)(4a − 3x − 5m − 1)= c2 − (a − 1) = (7 x 2 + 5x − 3 y )(7 x 2 − 5x + 3 y ) 234. 9m − a + 2acd − c d + 100 − 60m 222 2= (c + a − 1)(c − a + 1) 25. a − 2ab + b − c − 2cd − d= − (a − 2acd + c d ) + (9m2 − 60m + 100)2 2 2 222 2 = (a − b) − (c + d )= (3m − 10) − (a − cd ) 2217. 9 − n − 25 − 10n 2 2 2= 9 − (n + 10n + 25) 2 = (a − b + c + d )(a − b − c − d )= (3m − 10 + a − cd )(3m − 10 − a + cd )= 9 − (n + 5) 2 26. x + 2 xy + y − m + 2mn − n22 2235. 4a − 9 x + 49b − 30 xy − 25 y − 28ab 222 2= (3 + n + 5)(3 − n − 5) = ( x + y) − (m − n) = (4a 2 − 28ab + 49b 2 ) − (9 x 2 + 30 xy + 25 y 2 ) 22= − (n + 8)(n + 2) = ( x + y + m − n)( x + y − m + n)= (2a − 7b) − (3x + 5 y ) 2 2 27. a + 4b + 4ab − x − 2ax − a22 22 = (2a − 7b + 3x + 5 y )(2a − 7b − 3x − 5 y )18. 4a − x + 4 x − 42 2 = (a + 4ab + 4b ) − ( x + 2ax + a) 36. 225a − 169b + 1 + 30a + 26bc − c2 2 2 2 22 2= 4a 2 − ( x 2 − 4 x + 4) = (225a 2 + 30a + 1) − (169b 2 − 26bc + c 2 ) = (a + 2b) − ( x + a ) 22= 4a 2 − ( x − 2) 2 = (15a + 1) − (13b − c) = (a + 2b + x + a )(a + 2b − x − a) 2= (2a + x − 2)(2a − x + 2) = (15a + 1 + 13b − c)(15a + 1 − 13b + c) = (2a + 2b + x )(2b − x )37. x − y + 4 + 4 x − 1 − 2 y 2 219. 1 − a − 9n − 6an 2 2 28. x + 4a − 4ax − y − 9b + 6by22 22= 1 − (a 2 + 6an + 9n 2 )= ( x 2 + 4 x + 4) − ( y 2 + 2 y + 1) = ( x 2 − 4ax + 4a 2 ) − ( y 2 − 6by + 9b2 )= 1 − (a + 3n) = ( x + 2) − ( y + 1) 2 2 2 = ( x − 2a ) − ( y − 3b) 22= (a + 3n + 1)(1 − a − 3n) = ( x + 2 + y + 1)( x + 2 − y − 1) = ( x − 2a + y − 3b)( x − 2a − y + 3b) = ( x + y + 3)( x − y + 1)20. 25 − x − 16 y + 8 xy22 29. m − x + 9n + 6mn − 4ax − 4a2 22 238. a − 16 − x + 36 + 12a − 8 x 22= 25 − ( x 2 − 8 xy + 16 y 2 ) = (m2 + 6mn + 9n 2 ) − ( x 2 + 4ax + 4a 2 )= (a + 12a + 36) − ( x 2 + 8 x + 16)2= 25 − ( x − 4 y ) = (m + 3n) − ( x + 2a ) 2 = (a + 6) − ( x + 4) 222 2= (5 + x − 4 y)(5 − x + 4 y )= (m + 3n + x + 2a )(m + 3n − x − 2a )= (a + 6 + x + 4)(a + 6 − x − 4) = (a + x + 10)(a − x + 2)
• 103. 7. 4a + 3a b + 9b 14. c − 45c + 100 42 2 44 2EJERCICIO 96 + 9a 2b 2− 9a 2b 2 + 25c2− 25c21. a 4 + a 2 + 1 4a 4 + 12a 2b 2 + 9b 4 − 9a 2b 2 c4 − 20c2 + 100 − 25c2 = (2a 2 + 3b ) = (c2 − 10) − 25c2 2 22 + a2− a2 − 9a 2b 2 (a + 2a + 1) − a 422 = (2a 2 + 3ab + 3b 2 )(2a 2 − 3ab + 3b 2 ) = (c2 + 5c − 10)(c2 − 5c − 10) = (a + 1) − a8. 4 x − 29 x + 2524 215. 4a − 53a b + 49b2284 4 8 = (a + a + 1)(a − a + 1)22 + 9x2− 9 x2+ 25a 4b 4 − 25a 4b 4 4 x 4 − 20 x 2 + 25 − 9 x 24a 8 − 28a 4b 4 + 49b8 − 25a 4b 42. m + m n + n = (2 x 2 − 5) − 9 x 2= (2a 4 − 7b 4 ) − 25a 4b 442 2 42 2+ m2 n 2 − m2 n 2 = (2 x 2 + 3x − 5)(2 x 2 − 3x − 5) = (2a 4 + 5a 2b 2 − 7b 4 )(2a 4 − 5a 2b 2 − 7b 4 ) m4 + 2 m2 n 2 + n 4 − m2 n 29. x + 4 x y + 16 y8 4 4 816. 49 + 76n 2 + 64n 4 = (m2 + n 2 ) − m2 n 22 + 4x4 y4 − 4x4 y4+ 36n 2 − 36n 2 = (m2 + n 2 + mn)(m2 + n 2 − mn) x 8 + 8 x 4 y 4 + 16 y 8 − 4 x 4 y 4 49 + 112n 2 + 64n 4 − 36n 23. x + 3x + 4= (x 4 + 4 y 4 ) − 4 x 4 y 4 = (7 + 8n2 ) − 36n 2842 2 + x−x= (8n 2 + 6n + 7)(8n 2 − 6n + 7)44 = ( x 4 + 2 x 2 y 2 + 4 y 4 )( x 4 − 2 x 2 y 2 + 4 y 4 )x + 4x + 4 − x 84410. 16m − 25m n + 9n17. 25x − 139 x y + 81y4 2 2 442 2 4 = ( x 4 + 2) − x 42+mn 2 2−m n 2 2 + 49 x 2 y 2 − 49 x 2 y 2 = (x 4 + x 2 + 2)(x 4 − x 2 + 2)16m − 24m n + 9n − m n 25x 4 − 90x 2 y 2 + 81y 4 − 49 x 2 y 24 2 2 4 2 2 = (4m2 − 3n2 2) − m2 n 2= (5x 2 − 9 y 2 ) − 49 x 2 y 224. a + 2a + 942 + 4a 2 − 4a 2 = (4m2 + mn − 3n2 )(4m2 − mn − 3n2 ) = (5x 2 + 7 xy − 9 y 2 )(5x 2 − 7 xy − 9 y 2 ) a 4 + 6a 2 + 9 − 4a 211. 25a 4 + 54a 2b 2 + 49b 418. 49 x + 76 x y + 100 y84 48 = (a 2 + 3) − 4a 2 + 16a b − 16a b2 2 2 2 2+ 64 x 4 y 4− 64 x 4 y 4 = (a 2 + 2a + 3)(a 2 − 2a + 3)25a + 70a b + 49b − 16a b49 x 8 + 140 x 4 y 4 + 100 y 8 − 64 x 4 y 44 2 2 42 2 = (5a + 7b 2 2) = (7 x 4 + 10 y 4 ) − 64 x 4 y 422− 16a b 2 25. a 4 − 3a 2b 2 + b 4 = (5a 2 + 4ab + 7b 2 )(5a 2 − 4ab + 7b 2 ) = (7 x 4 + 8 x 2 y 2 + 10 y 4 )(7 x 4 − 8 x 2 y 2 + 10 y 4 ) + a 2b 2− a 2b 212. 36 x 4 − 109 x 2 y 2 + 49 y 4 19. 4 − 108 x + 121x2 4 a 4 − 2a 2b 2 + b 4 − a 2b 2+ 25x y 2 2− 25x y22+ 64 x 2− 64 x 2 = (a 2 − b2 ) − a 2b 22 36x 4 − 84 x 2 y 2 + 49 y 4 − 25x 2 y 24 − 44 x 2 + 121x 4 − 64 x 2 = (a 2 + ab − b2 )(a 2 − ab − b 2 ) = (6x 2 − 7 y 2 ) − 25x 2 y 2= (2 − 11x 2 ) − 64 x 22 26. x − 6 x + 1 = (6x 2 + 5xy − 7 y 2 )(6 x 2 − 5xy − 7 y 2 )= (2 + 8 x − 11x 2 )(2 − 8 x − 11x 2 )4 2 + 4x2− 4x213. 81m + 2m + 18420. 121x − 133x y + 36 y42 4 8x − 2 x + 1− 4 x 2 42+ 16m 4− 16m 4 + x2 y4− x2 y4 = ( x − 1) − 4 x2 22 81m + 18m + 1 − 16m8 4 4 121x 4 − 132 x 2 y 4 + 36 y 8 − x 2 y 4 = ( x + 2 x − 1)( x − 2 x − 1)= (9m + 1) − 16m = (11x 2 − 6 y 4 ) − x 2 y 4224 2 4 2 = (9m4 + 4m2 + 1)(9m4 − 4m2 + 1) = (11x 2 + xy 2 − 6 y 4 )(11x 2 − xy 2 − 6 y 4 )
• 104. 21. 144 + 23n 6 + 9n12 25. 1 − 126a b + 169a b2 44 8 + 49n 6 − 49n6+ 100a 2b 4 − 100a 2b 4 144 + 72n 6 + 9n12 − 49n 61 − 26a 2b 4 + 169a 4b8 − 100a 2b 4 = (12 + 3n 6 2)= (1 − 13a 2b 4 ) − 100a 2b 4 2− 49n 6 = (12 + 7n 3 + 3n 6 )(12 − 7n 3 + 3n 6 )= (1 + 10ab 2 − 13a 2b 4 )(1 − 10ab 2 − 13a 2b 4 )22. 16 − 9 c 4 + c826. x y + 21x y + 1214 4 2 2+ c4−c 4 + x2 y2− x2 y2 16 − 8c 4 + c8 − c4 x 4 y 4 + 22 x 2 y 2 + 121 − x 2 y 2 = (4 − c4 ) − c4= ( x 2 y 2 + 11) − x 2 y 22 2 = (4 + c 2 − c4 )(4 − c 2 − c4 )= ( x 2 y 2 + xy + 11)( x 2 y 2 − xy + 11)23. 64a − 169a b + 81b 27. 49c + 75c m n + 196m n4 2 48 842 2 4 4+ 25a 2b4− 25a 2b4 + 121c4 m2 n2− 121c4 m2 n 2 64a 4 − 144a 2b4 + 81b8 − 25a 2b4 49c8 + 196c4 m2 n 2 + 196m4 n 4 − 121c4 m2 n 2 = (8a 2 − 9b 4 2)= (7c4 + 14m2 n 2 ) − 121c4 m2 n 2 2− 25a 2b4 = (8a 2 + 5ab − 9b 4 )(8a 2 − 5ab − 9b 4 )= (7c4 + 11c2 mn + 14m2 n 2 )(7c 4 − 11c2 mn + 14m2 n 2 )24. 225 + 5m2 + m4 28. 81a b − 292a b x + 256 x 4 8 2 4 816 + 25m2 − 25m 2 + 4a b x 2 4 8− 4a 2b 4 x 8 225 + 30m2 + m4 − 25m281a 4b8 − 288a 2b 4 x 8 + 256 x16 − 4a 2b 4 x 8 = (15 + m2 ) − 25m2 = (9a 2b 4 − 16 x 8 ) − 4a 2b 4 x 822 = (m2 + 5m + 15)(m2 − 5m + 15)= (9a 2b 4 + 2ab 2 x 4 − 16 x 8 )(9a 2b 4 − 2ab 2 x 4 − 16 x 8 )EJERCICIO 97 4+ 64 y 44 + 324b 45. 4 + 625x 81. x 3. a + 16 x 2 y 2− 16 x 2 y 2 + 100 x 4 − 100 x 4+ 36a 2b 2− 36a 2b 24 + 100 x + 625x − 100 x 44 8x 4 + 16 x 2 y 2 + 64 y 4 − 16x 2 y 2a 4 + 36a 2b 2 + 324b 4 − 36a 2b 2= (2 + 25x 4 ) − 100 x 4 2= ( x 2 + 8 y 2 ) − 16 x 2 y 2 = (a 2 + 18b 2 ) − 36a 2b 222= (25x 4 + 10 x 2 + 2)(25x 4 − 10 x 2 + 2)= ( x 2 + 4 xy + 8 y 2 )( x 2 − 4 xy + 8 y 2 ) = (a 2 + 6ab + 18b 2 )(a 2 − 6ab + 18b 2 )2. 4 x 8+ y8 6. 64 + a 12 4. 4 m4+ 81n 4 + 4x4 y4 − 4x4 y4 + 16a 6− 16a 6+ 36m2n 2− 36m2 n 2 4x + 4x y + y − 4x y 8 44 84 464 + 16a 6 + a 12 − 16a 6 4m4 + 36m2 n 2 + 81n 4 − 36m2n 2= (2 x + y 4) 4 2− 4x y 4 4= (8 + a 6 ) − 16a 6 2= (2 x 4 + 2 x 2 y 2 + y 4 )(2 x 4 − 2 x 2 y 2 + y 4 ) = 2m + 9n ( 2 ) 2 2− 36m n2 2= (a 6 + 4a 3 + 8)(a 6 − 4a 3 + 8) = (2m 2 + 6mn + 9n 2 )(2m2 − 6mn + 9n 2 )
• 105. 7. 1 + 4n 48. 64 x 8+ y89. 81a 4 + 64b 4+ 4n 2− 4n 2 + 16 x y44 − 16 x y 44 + 144a b 2 2 − 144a 2b 2 1 + 4 n 2 + 4n 4 − 4n 264 x 8 + 16 x 4 y 4 + y 8 − 16 x 4 y 481a 4 + 144a 2b2 + 64b 4 − 144a 2b2 = (1 + 2n2 ) − 4n2 = (8 x 4 + y 4 ) − 16 x 4 y 4= (9a 2 + 8b 2 ) − 144a 2b222 2 = (2n2 + 2n + 1)(2n2 − 2n + 1)= (9a 2 + 12ab + 8b2 )(9a 2 − 12ab + 8b 2 )= (8 x 4 + 4 x 2 y 2 + y 4 )(8 x 4 − 4 x 2 y 2 + y 4 )EJERCICIO 98()( )1. x 2 + 7 x + 10 = x + 5 x + 2( 27. a 2 − 14a + 33 = a − 11 a − 3)() 37. m − 2m − 16822. x − 5x + 6 = ( x − 3)( x − 2)168 2 2 28. m2 + 13m − 30 = m + 15 m − 2( )( )84 2 2 ⋅ 2 ⋅ 3 = 123. x + 3x − 10 = ( x + 5)( x − 2) 2 2( )( ) 29. c − 13c − 14 = c − 14 c + 1 42 2 2 ⋅ 7 = 144. x + x − 2 = ( x + 2)(x − 1) 2 30. x 2 + 15x + 56 = ( x + 8)( x + 7) 21 3⇒ 14 − 12 = 2 − 15x + 54 = ( x − 9)( x − 6) = (m − 14)(m + 12)5. a + 4a + 3 = (a + 3)(a + 1) 2 31. x 2 77 + 7a − 60 = (a + 12)(a − 5)16. m + 5m − 14 = (m + 7)(m − 2) 2 32. a 238. c + 24c + 135 27. y − 9 y + 20 = ( y − 5)( y − 4) 33. x − 17 x − 60 22135 38. x − x − 6 = ( x − 3)( x + 2) 60 2 245 3 3⋅ 3 = 9 30 22 ⋅ 2 ⋅ 5 = 20 3⋅ 5 = 159. x − 9 x + 8 = ( x − 8)( x − 1)15 3 3⋅ 1 = 3 2 15 3 5 5 ⇒ 15 + 9 = 2410. c + 5c − 24 = (c + 8)(c − 3) 2 5 5 ⇒ 20 − 3 = 171= (c + 15)(c + 9) = ( x − 20)( x + 3)11. x − 3x + 2 = ( x − 2)( x − 1) 2 139. m − 41m + 400 212. a + 7a + 6 = (a + 6)(a + 1)34. x + 8 x − 1802 2400 2 180 213. y − 4 y + 3 = ( y − 3)( y − 1) 2 90 22 ⋅ 3⋅ 3 = 18 200 2 2 4 = 1652 = 2514. n − 8n + 12 = (n − 6)(n − 2)100 2 2 45 3 2 ⋅ 5 = 1050 2 ⇒ 25 + 16 = 413 ⇒ 18 − 10 = 815. x + 10 x + 21 = ( x + 7)( x + 3) 15 = (m − 25)(m − 16) 2= ( x + 18)( x − 10) 255 5516. a + 7a − 18 = (a + 9)(a − 2) 255 117. m − 12m + 11 = (m − 11)(m − 1) 21 35. m − 20m − 300218. x − 7 x − 30 = ( x − 10)( x + 3)40. a + a − 380 2 2 300 2380 219. n + 6n − 16 = (n + 8)(n − 2) 2 150 2 2 ⋅ 3⋅ 5 = 30 75 32 ⋅ 5 = 10 190 22 2 ⋅ 5 = 2020. a − 21a + 20 = (a − 20)(a − 1) 2 25 5 ⇒ 30 − 10 = 20 95519 ⋅ 1 = 1921. y + y − 30 = ( y + 6)( y − 5) 19 ⇒ 20 − 19 = 1= (m − 30)(m + 10) 219 55 = (a + 20)(a − 19)22. a − 11a + 28 = (a − 7)(a − 4)1 2 123. n − 6n − 40 = (n − 10)(n + 4) 41. x + 12 x − 364 2 36. x + x − 1322 2 132 2364 224. x − 5x − 36 = ( x − 9)( x + 4) 2 2 ⋅ 13 = 26 662 2 ⋅ 2 ⋅ 3 = 12 182 225. a − 2a − 35 = (a − 7)(a + 5) 2 333 11⋅ 1 = 11917 2 ⋅ 7 = 14 11 ⇒ 12 − 11 = 113 ⇒ 26 − 14 = 1226. x + 14 x + 13 = ( x + 13)( x + 1) 2 11 13 1= ( x + 12)( x − 11)1= ( x + 26)( x − 14)
• 106. 42. a + 42a + 432 2 47. c − 4c − 3202 45. x − 2 x − 5282432 2216 2 2 3 ⋅ 3 = 24 528 2 320 2108 2 2 ⋅ 32 = 18 264 2 2 3 ⋅ 3 = 24160 22 4 = 16542 ⇒ 24 + 18 = 42132 22 ⋅ 11 = 22802 22 ⋅ 5 = 20273 = (a + 24)(a + 18)66 2 ⇒ 24 − 22 = 2402 ⇒ 20 − 16 = 49 3 33 3 = ( x − 24)( x + 22) 202 = (c − 20)(c + 16)3 3 11 11 1021 1 5 5143. m − 30m − 6752675 3 46. n + 43n + 4322225 5 3⋅ 5⋅ 3 = 45 48. m − 8m − 1. 008 432 2245 33⋅ 5 = 15216 22 = 16 4 1. 008 215 3 ⇒ 45 − 15 = 30108 233 = 27504 22 2 ⋅ 7 = 285 5 = (m − 45)(m + 15)54 2 ⇒ 16 + 27 = 43 252 22 2 ⋅ 32 = 36 3 = (n + 16)(n + 27)127126 2 ⇒ 36 − 28 = 844. y 2 + 50 y + 33693633 = (m − 36)(m + 28)336 33 3 213112 2 3⋅ 7 ⋅ 2 = 421 7 75622 =8 31282 ⇒ 42 + 8 = 50142 = ( y + 42)( y + 8)7 7118. a b − 2a b − 99 4 42 2 13. x 4 + 7ax 2 − 60a 2EJERCICIO 99= ( x 2 + 12a )( x 2 − 5a )99 33⋅ 3 = 91. x + 5x + 4 = (x + 4)( x + 1)4 2 22 14. ( 2 x ) − 4 ( 2 x ) + 3 233 3 11⋅ 1 = 1111 11 ⇒ 11 − 9 = 22. x 6 − 6 x 3 − 7 = ( x 3 − 7)( x 3 + 1) = (2 x − 3)(2 x − 1) 1= (a 2b2 − 11)(a 2b 2 + 9)3. x 8 − 2 x 4 − 80 = (x4− 10)(x 4 + 8) 15. (m − n) + 5 (m − n) − 24 219. c + 11cd + 28d 2 2 (4. x 2 y 2 + xy − 12 = xy + 4 xy − 3 )()= (m − n + 8)(m − n − 3)= (c + 7d )(c + 4d ))( )5. ( 4 x ) − 2 ( 4 x ) − 15 = 4 x − 5 4 x + 3( 16. x + x − 24020. 25x − 5 (5x ) − 842 8 42+ 13(5x) + 42 = (5x + 7)(5x + 6) 240 284 26. (5x ) 2 120 2 24 = 1642 22 2 ⋅ 3 = 12 ( )( )7. x 2 + 2ax − 15a 2 = x + 5a x − 3a60 23⋅ 5 = 15 21 3 7 ⋅1 = 78. a − 4ab − 21b = (a − 7b)(a + 3b)2 230 2 ⇒ 16 − 15 = 17 7 ⇒ 12 − 7 = 59. ( x − y ) + 2 ( x − y ) − 24 = ( x − y + 6)( x − y − 4)2 153 = ( x 4 + 16)( x 4 − 15) 1 = (5x − 12)(5x + 7) 5 510. − x + 4 x + 5 21. a − 21ab + 98b2 22= − ( x 2 − 4 x − 5) = − ( x − 5)(x + 1) = (5 − x )(x + 1) 198 2 2 ⋅ 7 = 14 17. − y + 2 y + 152 7 ⋅1= 7 x + x 5 − 20 = (x 5 + 5)(x 5 − 4)49 710= − ( y − 2 y − 15)11.27 7 ⇒ 14 + 7 = 2112. m2 + mn − 56n 2 = m + 8n ()(m − 7n) = − ( y − 5 )( y + 3) = (5 − y )( y + 3) 1 = (a − 14b)(a − 7b)
• 107. 22. x y + x y − 132 4 4 2 227. − n 2 + 5n + 14 32. − x 2 + 4ax + 21a 2132 2= − (n − 5n − 14) 2 = − ( x 2 − 4ax − 21a 2 ) 2 ⋅ 2 ⋅ 3 = 12 = − (n − 7)(n + 2) = (7 − n)(n + 2) = − ( x − 7a)(x + 3a )66 233311⋅ 1 = 1128. x + x − 93063 = (7a − x )( x + 3a )1111 ⇒ 12 − 11 = 1 = ( x 2 y 2 + 12)( x 2 y 2 − 11)930 21 33. x 8 y 8 − 15x 4 y 4 − 100a 2 465 5 2 ⋅ 5⋅ 3 = 3023. − x + 2 x + 48= ( x 4 y 4 − 20a )( x 4 y 4 + 5a )42 93331⋅ 1 = 31 = − (x − 2 x − 48)42 3131 ⇒ 31 − 30 = 134. (a − 1) + 3 (a − 1) − 1082 = − (x 2 − 8)(x 2 + 6) = (8 − x 2 )( x 2 + 6)1 = ( x 3 + 31)( x 3 − 30) 108 224. (c + d ) − 18(c + d ) + 6529. (4 x ) − 8 (4 x 2 ) − 105 2 2 2 54 2 2 2 ⋅ 3 = 12 = (c + d − 13)(c + d − 5)105 527 3 32 = 925. a + 2axy − 440 x y2 2 2 21 35⋅ 3 = 1593⇒ 12 − 9 = 3440 2 777 ⋅1= 733 = (a − 1 + 12)(a − 1 − 9) 2 ⋅ 5 = 20 1 ⇒ 15 − 7 = 8 = (a + 11)(a − 10) 2 220 2 1110 2 11⋅ 2 = 22= (4 x 2 − 15)(4 x 2 + 7)555⇒ 22 − 20 = 235. m + abcm − 56a b c 22 2 230. x 4 + 5abx 2 − 36a 2b 21111 = (a + 22 xy )(a − 20 xy )= (m + 8abc )(m − 7abc)1 = ( x 2 + 9ab)( x 2 − 4ab)36. (7 x) + 24(7 x 2 ) + 128 2 226. m n − 21m n + 104 6 6 3 331. a − a b − 156b 4 2 2 4104 2128 4156 2 4 2 = 16522 2 =83 32 426213⋅ 1 = 137822 ⋅ 3 = 12 2 844⋅2 = 81313 ⇒ 13 + 8 = 21 39313⋅ 1 = 13 2 2 ⇒ 16 + 8 = 2413 ⇒ 13 − 12 = 1 = (m3n3 − 13)(m3n 3 − 8)= (7 x 2 + 16)(7 x 2 + 8)13111= (a 2 − 13b 2 )(a 2 + 12b 2 )EJERCICIO 1007. 4a + 15a + 9 210.20 y + y − 1 24. 5x + 13x − 6 = 16a 2 + 15( 4a ) + 3621. 2 x + 3 x − 22 = 400 y 2 + 1(20 y ) − 20 = 4 x 2 + 3 (2 x ) − 4= 25x 2 + 13 (5x ) − 30(4a + 12)(4a + 3)(5x + 15)(5x − 2)= (20 y + 5)(20 y − 4) (2 x + 4)(2 x − 1)4= ==5 = (a + 3)(4a + 3)5⋅ 4= (4 y + 1)(5 y − 1) 2 = ( x + 2)(2 x − 1)= ( x + 3)(5x − 2)8. 10a + 11a + 32= 100a 2 + 11(10a ) + 305. 6 x − 5x − 622. 3x − 5x − 22= 36 x 2 − 5 ( 6 x) − 36(10a + 6)(10a + 5)11. 8a 2 − 14a − 15 = 9 x 2 − 5 ( 3x ) − 6 = 2⋅5= 64 a 2 − 14 (8a) − 120 (3x − 6)(3x + 1) =(6x − 9)(6x + 4)= (5a + 3)(2a + 1) =3⋅ 2120 2 39. 12m2 − 13m − 3560 2 2 ⋅ 2 ⋅ 5 = 20 = ( x − 2)(3x + 1) = (2 x − 3)(3x + 2)= 144m2 − 13(12m) − 42030 2 2⋅ 3= 63. 6 x + 7 x + 26. 12 x − x − 64 ⋅ 7 = 2822420415 3 ⇒ 20 − 6 = 14 = 36x + 7 ( 6x) + 12 = 144 x 2 − 1(12 x) − 72 5⋅ 3 = 15 (8a − 20)(8a + 6)2 1055 3 ⇒ 28 − 15 = 13 (6x + 4)(6x + 3) (12 x − 9)(12 x + 8)5 =2154⋅ 2 ==(12m − 28)(12m + 15)2⋅ 3 3⋅ 4 77 = 4⋅31 = (2a − 5)(4a + 3) = (3x + 2)(2 x + 1)= (4 x − 3)(3x + 2) 1= (3m − 7)(4m + 5)
• 108. 17. 20n − 9n − 202 23. 14m − 31m − 10 212. 7 x − 44 x − 35 2= 400n − 9( 20) − 400 2 = 196m2 − 31(14m) − 140= 49 x 2 − 44 (7 x) − 245 400 2140 2245 5200 2 2 4 = 16 7025⋅ 7 = 3549 77 ⋅ 7 = 49 35 5 2⋅2 = 4 100 252 = 2577 5⋅1 = 5 7 7 ⇒ 35 − 4 = 31 50 2⇒ 25 − 16 = 91⇒ 49 − 5 = 44(14m − 35)(14m + 4) (7 x − 49)(7 x + 5)25 5 = (20n − 25)(20n + 16)1=7⋅2 = 5⋅ 4 = (2m − 5)(7m + 2) 7 = ( x − 7)(7 x + 5) 5 5 = (4n − 5)(5n + 4)24. 2 x + 29 x + 902 1 = 4 x 2 + 29 (2 x ) + 180 18. 21x + 11x − 22 180213. 15m + 16m − 15= 441x 2 + 11(21x) − 42 2 90 2 22 ⋅ 5 = 20= 225m2 + 16 (15m) − 225=(21x + 14)(21x − 3)45 3 32 = 9225 57⋅ 315 3 ⇒ 20 + 9 = 29 5⋅ 5 = 25= (3x + 2)(7 x − 1)45 5933⋅ 3 = 9 5 5=(2 x + 20)(2 x + 9) 19. 15m2 + m − 6 233 ⇒ 25 − 9 = 16= 225m2 + 15m − 90= (2 x + 10)(2 x + 9) (15m + 25)(15m − 9) 11=5⋅ 3=(15m + 10)(15m − 9)25. 20a − 7a − 402 5⋅ 3= 400a 2 − 7 (20a ) − 800 = (3m + 5)(5m − 3)= (3m + 2)(5m − 3) 8004 2004 42 ⋅ 2 = 32 20. 15a − 8a − 12 214. 2a + 5a + 252 = 25 2 50 5 = 225a 2 − 8 (15a ) − 180= 4a + 5 ( 2a ) + 4 2 10 5 ⇒ 32 − 25 = 7(2a + 4)(2a + 1) 180 22 =(20a − 32)(20a + 25)= 90 2 2 ⋅ 32 = 18 24⋅5 245 55⋅ 2 = 10 = (5a − 8)(4a + 5)= (a + 2)(2a + 1) 193 ⇒ 18 − 10 = 826. 4n + n − 33233=(15a − 18)(15a + 10) = 16n2 + 4n − 13215. 12 x − 7 x − 1223⋅ 5132 2= 144 x 2 − 7 (12 x) − 144 = (5a − 6)(3a + 2) 1 66 22 2 ⋅ 3 = 12144 2 21. 9 x + 37 x + 411⋅ 1 = 11 2 33 324 = 16 = 81x 2 + 37 ( 9 x ) + 3672 2 11 11 ⇒ 12 − 11 = 132 = 936 2(9 x + 36)(9 x + 1) =(4n + 12)(4n − 11)18 2 ⇒ 16 − 9 = 7 =1 9493 = (12 x − 16)(12 x + 9)= (x + 4)(9 x + 1)= (n + 3)(4n − 11)4⋅327. 30 x 2 + 13x − 10 22. 20n + 44n − 15 233 = (3x − 4)(4 x + 3) = 400n2 + 44 ( 20n) − 300 = 900 x 2 + 13 ( 30 x ) − 3001300 2 300 2 150 2 2 ⋅ 5 = 50 2150 252 = 2516. 9a + 10a + 12 75 52⋅ 3= 6 7552 ⋅ 3 = 122= 81a 2 + 10 ( 9a ) + 915 5 ⇒ 50 − 6 = 44155 ⇒ 25 − 12 = 13=(9a + 9)(9a + 1) (20n + 50)(20n − 6)(30 x + 25)(30x − 12)33 = 3 3 = 910 ⋅ 25⋅ 6= (a + 1)(9a + 1)1 = (2n + 5)(10n − 3) 1= (6 x + 5)(5x − 2)
• 109. EJERCICIO 101 7. − 10 x 2 − 7 x + 12 12. 7 x 6 − 33x 3 − 101. 6 x + 5x − 6 = − (10 x 2 + 7 x − 12) = (7 x 3 ) − 33 (7 x 3 ) − 704 22 = (6 x 2 2) + 5 (6 x 2 ) − 36 [= − (10x ) + 7 (10 x ) − 1202 ](7 x 3 − 35)(7 x 3 + 2)= = (6x2+ 9)(6 x 2 − 4)120 2 73⋅ 2 60 25⋅ 3 = 15= ( x 3 − 5)(7 x 3 + 2)2 3=8 = (2 x 2 + 3)(3x 2 − 2) 30 2 13. − 3a 2 + 13a + 30 15 5 ⇒ 15 − 8 = 72. 5x 6 + 4 x 3 − 12= − (3a 2 − 13a − 30) [ − (10x + 15)(10x − 8) ] = (5x )3 2+ 4 (5x 3 ) − 603 3 =5⋅ 2= − (9a 2 − 13 ( 3a ) − 90) (5x3+ 10)(5x 3 − 6)1= − (2 x + 3)(5x − 4) =− (3a − 18)(3a + 5) == (2 x + 3)(4 − 5x )53 = (x + 2)(5x − 6)3 3 = − (a − 6)(3a + 5)8. 21x − 29 xy − 72 y2 2= (6 − a )(3a + 5)3. 10 x + 29 x + 10= 441x 2 − 29 (21xy ) − 1.512 y 28 4 = (10 x) + 29 (10 x 4 ) + 100 14. − 6 x + 7 x + 58 44 21. 512 2 (10 x+ 25)(10 x 4 + 4)2 ⋅ 7 = 56= − (6 x 8 − 7 x 4 − 5) 347562 =3 = 27 ( ) 3= − (6 x 4 ) − 7 (6 x 4 ) − 30 3782 5⋅ 2 2 1893⇒ 56 − 27 = 29 = (2 x 4 + 5)(5x 4 + 2) (21x − 56 y)(21x + 27 y)(6 x4 − 10)(6 x + 3)4 63 3==−4. 6a x + 5ax − 21 2 2 7⋅32⋅ 3 (6ax ) 2 + 5 ( 6ax ) − 12621 3= (3x − 8 y )(7 x + 9 y )= − (3x 4 − 5)(2 x 4 + 1) 1262= (5 − 3x 4 )(2 x 4 + 1) 77 63 3 2 ⋅ 7 = 14 1 2173⋅ 3 = 99. 6m − 13am − 15a 2 2 15. 6a 2 − ax − 15x 2 33 ⇒ 14 − 9 = 5 = 36m − 13 (6am) − 90a22= 36a 2 − 6ax − 90 x 2=(6ax + 14)(6ax − 9) (6m − 18a )(6m + 5a ) (6a − 10x)(6a + 9 x) 1 == 2⋅3 6 2⋅3= (3ax + 7)(2ax − 3) = (m − 3a )(6m + 5a )= (3a − 5x )(2a + 3x )5. 20 x y + 9 xy − 20 10. 14 x − 45x − 14 2 242 16. 4 x + 7mnx − 15m n22 2 = (20 xy) + 9 (20 xy) − 400 = (14 x 2 ) − 45 (14 x 2 ) − 1962= ( 4 x) + 7mn ( 4 x) − 60m2n 222 400 2196 2=(4 x + 12mn )(4 x − 5mn) 200 252 = 2598 2 7 ⋅ 7 = 49 4 100 224 = 1649 72⋅2 = 4= ( x + 3mn)(4 x − 5mn) 50 2 ⇒ 25 − 16 = 9 7 ⇒ 49 − 4 = 45 7 17.18a + 17ay − 15y 2 2 25 5 =(20xy + 25)(20xy − 16) (14 x 2 − 49)(14 x 2 + 4)= (18a ) + 17 y (18a ) − 270 y 225⋅ 41= 270 27⋅2= (4 xy + 5)(5xy − 4) 33 = 27 = (2 x 2 − 7)(7 x 2 + 2) 55135 5 1 273 5⋅ 2 = 1011. 30a − 13ab − 3b2 26. 15x − ax − 2a22 9 3 ⇒ 27 − 10 = 17 = (15x) − a (15x ) − 30a 22= 900a 2 − 13 (30ab) − 90b 2 3 3 = (18a + 27 y)(18a − 10 y) (15x − 6a)(15x + 5a)= (30a − 18b)(30a + 5b) 9⋅2 =6⋅ 5 1 = (2a + 3 y )(9a − 5 y )3⋅ 5 = (5x − 2a )(3x + a ) = (5a − 3b)(6a + b)
• 110. 18. − 8 x + 2 x + 1523. − 6 y 2 + 11xy − 4 x 2 4 2 = − (8 x 4 − 2 x 2 − 15) = − (6 y 2 − 11xy + 4 x 2 )21. 30m + 17am − 21a 2 2 ( = − (8 x 2 ) − 2 (8 x 2 ) − 1202) = (30m) + 17a ( 30m) − 630a 2 2 (= − (6 y ) − 11x(6 y ) + 24 x 22 )(8x 2− 12)(8 x 2 + 10)6302=− (6 y − 8x)(6 y − 3x) =− 31555⋅ 7 = 35 2⋅ 3 4⋅ 22 ⋅ 32 = 18= − (3 y − 4 x )(2 y − x )63 3 = − (2 x 2 − 3)(4 x 2 + 5) 21 3 ⇒ 35 − 18 = 17= (4 x − 3y )(2 y − x ) = (3 − 2 x 2 )(4 x 2 + 5)77 = (30m + 35a)(30m − 18a)5⋅ 619. − 25x + 5x + 68 4= (6m + 7a )(5m − 3a ) = − (25x 8 − 5x 4 − 6)1 ( = − (25x 4 ) − 5 (25x 4 ) − 1502)24. − 20a + 27ab − 9b22 (25x 4− 15)(25x 4 + 10) = − (20a 2 − 27ab + 9b 2 ) =− 5⋅ 5(= − ( 20a ) − 27b(20a ) + 180b 2 2 )22. − 15a + 16a − 4 2 = − (5x − 3)(5x + 2)4 4 1802= − (15a 2 − 16a + 4) 2 2 ⋅ 3 = 12 = (3 − 5x)(5x+ 2)90 2 ( )4 4= − (15a ) − 16 (15a ) + 605⋅ 3 = 15 245 520. 30 x − 91x − 30105 (15a − 10)(15a − 6)9 3 ⇒ 15 + 12 = 27 = (30 x5 2) − 91(30 x ) − 900 5 =− 5⋅ 3(20a − 15b)(20a − 12b)33=− = (30x 5− 100)(30 x + 9)5= − (3a − 2)(5a − 2) 5⋅ 4= − (4a − 3b)(5a − 3b) 10 ⋅ 3 = (3a − 2)(2 − 5a )1 = (3x − 10)(10 x + 3)5 5 = (4a − 3b)(3b − 5a )EJERCICIO 102(12. 8 + 36 x + 54 x 2 + 27 x 3 = 2 + 3x ) 31. a 3 + 3a 2 + 3a + 1 = a + 1( )313. 8 − 12a 2 − 64a 4 − a 6 = No es cubo perfecto2. 27 − 27 x + 9 x − x = 3 − x2 3( )314. a 6 + 3a 4b3 + 3a 2b6 + b9 = (a 2 + b3 )33. m3 + 3m2 n + 3mn 2 + n 3 = m + n ( )3x 9 − 9 x 6 y 4 + 27 x 3 y 8 − 27 y12 = ( x 3 − 3 y 4 ) 315.4. 1 − 3a + 3a − a = 1 − a2 3( ) 316. 64 x 3 + 240 x 2 y + 300 xy 2 + 125 y 3 = 4 x + 5 y () 35. 8 + 12a2+ 6a + a = (2 + a4 6 2 3) 216 − 756a 2 + 882a 4 − 343a 6 = (6 − 7a 2 ) 317.)6. 125x 3 + 75x 2 + 15x + 1 = 5x + 1( 37. 8a − 36a b + 54ab − 27b = (2a − 3b) 32 2 3318. 125x 12 + 600 x 8 y 5 + 960 x 4 y10 + 512 y15 =(5x 4 + 8 y5 ) 3a18 + 3a 12 + 3a 6 + 1 = (a 6 + 1) 38. 27m + 108m n + 144mn + 64n = (3m + 4n) 32 2 3319.9. x 3 − 3x 2 + 3x + 1 = No es cubo perfecto20. m3 − 3am2 n + 3a 2 mn 2 − a 3n 3 = m − an ( )310. 1 + 12a 2b − 6ab − 8a 3b 3 = No es cubo perfecto21. 1 + 18a 2b 3 + 108a 4b 6 + 216a 6b 9 = (1+ 6a b )2 3 3()− 125 y = (4 x − 5 y ) 4 3 311. 125a 3 + 150a 2b + 60ab2 + 8b3 = 5a + 2b22. 64 x 9 − 240x 6 y 4 + 300 x 3 y 8 12 3
• 111. EJERCICIO 103 (1+ 7n)(1− 7n + 49n ) 20. 1 + 343n 3 = 21. 1 + a = (1 + a )(1 − a + a ) 3 21. 64a − 729 = (4a − 9)(16a + 36a + 81) 2 322. 1 − a = (1 − a )(1 + a + a ) 3 22. a b − x = (ab − x )(a b + abx + x ) 2 3 3 62 2 2 2 43. x + y = (x + y)( x − xy + y )33 23. 512 + 27a = (8 + 3a )(64 − 24a + 9a ) 2 2 93 3 64. m − n = (m − n )(m + mn + n ) 3 3 24. x − 8 y = ( x − 2 y )( x + 2 x y + 4 y ) 2 2 6 12 2 4 4 2 4 85. a − 1 = (a − 1)(a + a + 1)3 25. 1 + 729 x = (1 + 9 x )(1 − 9 x + 81x ) 2 62 2 46. y + 1 = ( y + 1)( y − y + 1)3 26. 27m + 64n = (3m + 4n )(9m − 12mn + 16n ) 2 39 3 2 3 67. y − 1 = ( y − 1)( y + y + 1)3 27. 343x + 512 y = (7 x + 8 y )(49 x − 56 xy + 64 y ) 2 36 2 2 2 48. 8 x − 1 = (2 x − 1)(4 x + 2 x + 1)3 28. x y − 216 y = ( xy − 6 y )(x y + 6 xy + 36 y ) 2 3 69 2 3 2 4 5 69. 1 − 8 x = (1 − 2 x)(1 + 2 x + 4 x ) 3 29. a b x + 1 = (abx + 1)(a b x − abx + 1 ) 2 3 3 32 2 210. x − 27 = ( x − 3)( x + 3x + 9) 3 30. x + y = ( x + y )( x − x y + y ) 2 9 93 3 6 3 3 611. a + 27 = (a + 3)(a − 3a + 9) 3 31. 1. 000 x − 1 = (10 x − 1)(100 x + 10 x + 1) 2 3212. 8 x + y = (2 x + y )(4 x − 2 xy + y ) 3 3 32. a + 125b = (a + 5b )(a − 5a b + 25b ) 2 2 6 12 2 4 4 2 4 813. 27a − b = (3a − b)(9a + 3ab + b ) 3 3 33. x + y = ( x + y )( x − x y + y ) 2 2 1212 4 4 8 4 4 814. 64 + a = (4 + a )(16 − 4a + a ) 6 34. 1 − 27a b = (1 − 3ab)(1 + 3ab + 9a b ) 2 2 4 3 32 215. a − 125 = (a − 5)(a + 5a + 25) 3 35. 8 x + 729 = (2 x + 9)(4 x − 18 x + 81) 2 62 4 216. 1 − 216m = (1 − 6m)(1 + 6m + 36m ) 3 36. a + 8b = (a + 2b )(a − 2ab + 4b ) 2 3 12 4 2 4 817. 8a + 27b = (2a + 3b )(4 a − 6ab + 9b ) 3 6 37. 8 x − 125 y z = (2 x − 5 yz )(4 x + 10 x yz + 25 y z ) 2 2 2 4 9 3 63 2 6 3 2 2 418. x − b = ( x − b )( x + x b + b ) 6 9 2 38. 27m + 343n = (3m + 7n )(9m − 21m n + 49n ) 3 4 2 3 6 69 2 3 4 2 3 619. 8 x − 27 y = (2 x − 3 y )(4 x + 6 xy + 9 y ) 3 3 39. 216 − x = (6 − x )(36 + 6 x + x ) 2 2 12 4 4 8EJERCICIO 104)[( ) ( ) ] () 3 5. x + 2 y + 1 = x + 2 y + 1 x + 2 y − x + 2 y + 1 ( 21. 1 + ( x + y ) = (1 + x + y )[1 − ( x + y ) + ( x + y ) ]= (x + 2 y + 1)( x + 4 xy + 4 y − x − 2 y + 1) 3 22 2 6. 1 − (2a − b) = [1 − (2a − b)][1 + (2a − b) + (2a − b) ] = (1 + x + y )(1 − x − y + x + 2 xy + y )32 2 22. 1 − (a + b) = [1 − (a + b)][1 + (a + b) + (a + b) ] 3= (1 − 2a + b)(1 + 2a − b + 4a − 4ab + b ) 22 2 7. a + (a + 1) = (a + a + 1)[a − a (a + 1) + (a + 1) ]3 2 = (1 − a − b)(1 + a + b + a + 2ab + b ) 32 2 2 = (2a + 1)(a − a − a + a + 2a + 1)3. 27 + (m − n) = (3 + m − n)[9 − 3(m − n) + (m − n) ]2 2 2 3 2 = (2a + 1)(a + a + 1)2= (3 + m − n)(9 − 3m + 3n + m − 2mn + n ) 8. 8a − (a − 1) = [2a − (a − 1)][4a + 2a (a − 1) + (a − 1) ] 2 2 33 224. ( x − y) − 8 = ( x − y − 2)[( x − y) + 2 ( x − y) + 4] 3 2= (2a − a + 1)(4a + 2a − 2a + a − 2a + 1) 2 2 2= (x − y − 2)( x − 2 xy + y + 2 x − 2 y + 4) 2= (a + 1)(7a − 4a + 1) 22
• 112. ( )9. 27 x 3 − x − y 314. ( x − y ) − ( x + y )33 = [3x − ( x − y )][9 x + 3x ( x − y ) + ( x − y ) ] = [(x − y ) − (x + y )][( x − y ) + ( x − y )( x + y ) + ( x + y ) ] 2 2 2 2 = (3x − x + y )(9 x + 3x − 3xy + x − 2 xy + y ) 2 = ( x − y − x − y )( x − 2 xy + y + x − y + x + 2 xy + y ) 2 2 222 2 2 2 2 = (2 x + y )(13x − 5xy + y )2 = − 2 y (3x + y )22 210. (2a − b) − 27 15. (m − 2) + (m − 3) 333= (2a − b − 3)[(2a − b) + 3 (2a − b) + 9]= [(m − 2) + (m − 3)][(m − 2) − (m − 2)(m − 3) + (m − 3) ] 2 2 2= (2a − b − 3)(4a − 4ab + b + 6a − 3b + 9) 2 = (m − 2 + m − 3)(m − 4m + 4 − m + 5m − 6 + m − 6m + 9) 2 2 2 211. x − ( x + 2) = (2m − 5)(m − 5m + 7) 6 3 2= [ x − ( x + 2)][ x + x ( x + 2) + ( x + 2) ]16. (2 x − y ) + (3x + y ) 2 3 3 2 4 2= ( x − x − 2)( x + x + 2 x + x + 4 x + 4) = [(2 x − y ) + (3x + y )][(2 x − y ) − (2 x − y )(3x + y ) + (3x + y ) ] 2 2 2 4 3 2 2= ( x − x − 2) ( x + x + 3x + 4 x + 4) 2 4 = (2 x − y + 3x + y )(4 x − 4 xy + y − 6 x + xy + y + 9 x + 6 xy + y ) 3 2 2 2 2 2 2 212. (a + 1) + (a − 3) 3 3 = (5x ) (7 x + 3xy + 3 y )2 2 17. 8 (a + b) + (a − b)= (a + 1 + a − 3)[(a + 1) − (a − 3)(a + 1) + (a − 3) ] 3 3 2 2= [2 (a + b) + (a − b)][4 (a + b) − 2 (a + b)(a − b) + (a − b) ] 2 2= (2a − 2)(a + 2a + 1 − a + 2a + 3 + a − 6a + 9) 2 2 2= (2a + 2b + a − b)(4a + 8ab + 4b − 2a + 2b + a − 2ab + b )= (2a − 2)(a − 2a + 13) 2 2 2 2 2 2 2= (3a + b)(3a + 6ab + 7b )13. ( x − 1) − ( x + 2) 2 2 33 18. 64 (m + n) − 125= [ x − 1 − ( x + 2)][( x − 1) + (x − 1)( x + 2) + (x + 2) ] 3 2 2 = [4 (m + n) − 5][16 (m + n) + 4 (m + n) (5) + 25] 2= ( x − 1− x − 2)( x − 2 x + 1 + x + x − 2 + x + 4 x + 4) 2 2 2= − 3 (3x + 3x + 3) = − 9 (x + x + 1) 2 = (4m + 4n − 5)(16m + 32mn + 16n + 20m + 20n + 25) 2 2 2EJERCICIO 105243 − 32b5 = (3 − 2b)(81 + 54b + 36b 2 + 24b 3 + 16b 4 ) (a + 1)(a − a + a − a + 1) 10.1. a 5 + 1 = 4 3 2a 5 + b5c5 = (a + bc)(a 4 − a 3bc + a 2b2 c 2 − ab3c 3 + b4 c4 )2. a − 1 = (a − 1)(a + a + a + a + 1) 11. 5 4 3 2 12. m − a x7 7 73. 1 − x = (1− x)(1 + x + x + x + x ) 5 2 3 4 = (m − ax)(m6 + m5ax + m4 a 2 x 2 + m3a 3 x 3 + m2 a 4 x 4 + ma 5 x 5 + a 6 x 6 )4.a + b77= (a + b)(a 6 − a 5b + a 4b 2 − a 3b 3 + a 2b 4 − ab5 + b 6 ) 13. 1 + x 7 = (1+ x)(1− x + x 2 − x 3 + x 4 − x5 + x 6 ) 14. x 7 − y 75. m7 − n 7 = ( x − y)( x 6 + x 5 y + x 4 y 2 + x 3 y 3 + x 2 y 4 + xy5 + y 6 ) = (m − n)(m6 + m5n + m4 n2 + m3n3 + m2n 4 + mn5 + n 6 ) 15. a 7 + 2 .187 (a + 3)(a − 3a + 9a − 27a + 81)6. a 5 + 243 = 4 3 2= (a + 3)(a 6 − 3a 5 + 9a 4 − 27a 3 + 81a 2 − 243a + 729)7. 32 − m = (2 − m)(16 + 8m + 4m + 2m + m ) (1− 2a)(1+ 2a + 4a + 8a + 16a + 32a + 64a ) 5 2 3 4 16. 1 − 128a 7 =2 3 4 5 68. 1 + 243x = (1 + 3x )(1 − 3x + 9 x − 27 x + 81x ) 5 2 3 4 17. x10 + 32 y = (x + 2 y )(x − 2 x y + 4 x y − 8 x y + 16 y ) 528 6 4 2 2 3 49. x 7 + 12818. 1 + 128 x 4 = (x + 2)( x 6 − 2 x 5 + 4 x 4 − 8 x 3 + 16 x 2 − 32 x + 64)= (1 + 2 x 2 )(1 − 2 x 2 + 4 x 4 − 8 x 6 + 16x 8 − 32 x10 + 64 x12 )
• 113. EJERCICIO 106 (a + 1)(a − a + 1) 18. a 6 + 1 = 24 21. 5a + a = a 5a + 1 2( )19. 8m − 27 y = (2m − 3 y )(4m + 6my 3 62 22 + 9 y4 ) ( )2. m + 2mx + x = m + x2 223. a + a − ab − b = (a + a ) − (ab − b) 22 20. 16a 2 − 24ab + 9b 2 = 4a − 3b( ) 2 = a (a + 1) − b(a + 1)21. 1 + a 7 =(1+ a)(1− a + a 2− a3 + a4 − a5 + a6 ) = (a + 1)(a − b)22. 8a 3 − 12a 2 + 6a − 1 = 2a − 1 ( )34. x − 36 = x − 6 = ( x + 6)(x − 6) 22 2 23. 1 − m2= (1 + m)(1− m)5. 9 x − 6 xy + y = (3x − y ) x 4 + 4 x 2 − 21 = ( x 2 + 7)( x 2 − 3)2 22 24.6. x − 3x − 4 = ( x − 1)( x + 4) (5a + 1)(25a − 5a 2 + 1) 2 25. 125a 6 + 1 = 2 47. 6 x 2 − x − 2 26. a + 2ab + b − m2 22 = 36 x 2 − 6 x − 12 (6x − 4)(6x + 3) = (a + b) − m2 = (a + b + m)(a + b − m) 2 =3⋅ 2 27. 8a 2b + 16a 3b − 24a 2b 2 = 8a 2b 1 + 2a − 3b() = (3x − 2)(2 x + 1) 28. x 5 − x 4 + x − 1 (1+ x)(1− x + x )8. 1 + x 3 = = (x − x ) + (x − 1) = x (x − 1) + (x − 1) = ( x + 1)( x − 1) 2 5 4449. 27a − 1 = (3a − 1)(9a + 3a + 1)32 29. 6 x + 19 x − 20210. x + m = ( x + m)( x − x m + x m − xm + m )= 36x + 19 ( 6 x ) − 12025 54 3 2 2 3411. a − 3a b + 5ab = a (a − 3ab + 5b )120 23 2 22 260 22 ⋅ 3 = 24 312. 2 xy − 6 y + xz − 3z3025⋅1 = 5 = 2 y ( x − 3) + z ( x − 3) = ( x − 3)(2 y + z)153 ⇒ 24 − 5 = 1913. 1 − 4b + 4b 2 = 1 − 2b() 2 =(6x + 24)(6x − 5)5 514. 4 x + 3x y + y4 2 2 4 6+x y2 2−x y 2 21 = (x + 4)(6 x − 5) 4x + 4x y + y − x2 y225x 4 − 81y 2 = (5x 2 + 9 y)(5x 2 − 9 y)4 2 2 4 30. = (2 x 2 + y 2 ) − x 2 y 2 (1− m)(1+ m + m )2 31. 1 − m3 = 2 = (2 x + xy + y2 2)(2 x2 − xy + y2 ) 32. x − a + 2 xy + y + 2ab − b2 22215. x − 6 x y + y = ( x 2 + 2 xy + y 2 ) − (a 2 − 2ab + b2 )8 4 4 8+ 2x y4 4− 4x y 44= ( x + y ) − (a − b) 22 x − 2x y + y − 4x y= ( x + y + a − b)( x + y − a + b)8 4 4 84 4 = (x 4 − y 4 ) − 4 x 4 y 42 33.21m5n − 7m4 n 2 + 7m3n3 − 7m2 n = 7m2 n (3m3 − m2 n + mn 2 − 1) = ( x 4 + 2 x 2 y 2 − y 4 )( x 4 − 2 x 2 y 2 − y 4 ) () ( ) ( ) ()( 34. a x + 1 − b x + 1 + c x + 1 = a − b + c x + 1 )16. a 2 − a − 30 = a − 6 a + 5( )( ) 35. 4 + 4 ( x − y ) + (x − y) = (2 + x − y)2217. 15m + 11m − 14 2 = 225m2 + 11(15m) − 210 36. 1 − a 2b 4 =(1+ ab )(1− ab )2 2 = (15m + 21)(15m − 10)37. b 2 + 12ab + 36a 2 = b + 6a( )23⋅ 5x 6 + 4 x 3 − 77 = (x 3 + 11)( x 3 − 7) = (5m + 7)(3m − 2) 38.
• 114. 39. 15x − 17 x − 4(1+ 6x )(1− 6x + 36x ) 4 2 52. 1 + 216 x 9 = 3 3 6= (15x 2 2 ) − 17 (15x ) − 60 53 x − 64 = (x − 4)( x + 4 x + 16) 232=(15x 2 − 20)(15x + 3)2 54. x 3 − 64 x 4 = x 3 1 − 64 x ( )5⋅ 3= (3x 2 − 4)(5x 2 + 1) 55. 18ax y − 36 x y − 54 x 2 y 8 = 18 x 2 y 3 (ax 3 − 2 x 2 − 3 y 5 ) 5 3 4 340. 1 + a − 3b() 3 56. 49a 2b 2 − 14ab + 1 = 7ab − 1 ( ) ) ( ( )( ) ( )( ) [ ]2 57. x + 1 − 81 = x + 1 + 9 x + 1 − 9 = x + 10 x − 8= (1 + a − 3b) 1 − (a − 3b) + (a − 3b) 258. a − (b + c) = (a + b + c)(a − b − c) 2 2= (1 + a − 3b)(1 − a + 3b + a 2− 6ab + 9b )259. (m + n) − 6 (m + n) + 9 = (m + n − 3) 2 241. x + x+ 25 42 61. 9a + 63a − 45a 32 60. 7 x + 31x − 202+ 9x2− 9 x2= ( 7 x) + 31( 7 x) − 140 2 = 9a (a 2 + 7 − 5a )x 4 + 10 x 2 + 25 − 9 x 2 140262. ax + a − x − 1= (x 2 + 5) − 9 x 2= (ax + a ) − (x + 1) 2 70 27 ⋅ 5 = 35= (x + 3x + 5)(x − 3x + 5)223552 =42 = a (x + 1) − ( x + 1)42. a − 28a + 36847 7 ⇒ 35 − 4 = 31= (a − 1)( x + 1)+ 16a 4− 16a 4 1 = (7 x + 35)(7 x − 4) 63. 81x 4 + 25 y 2 − 90 x 2 y 7a 8 − 12a 4 + 36 − 16a 4 ⇒ 81x 4 − 90 x 2 y + 25 y 2 = ( x + 5)(7 x − 4)= (a 4 − 6) − 16a 4= (9 x 2 − 5 y ) 2 2 64. 1 − 27b + b24= (a 4 + 4a 2 − 6)(a 4 − 4a 2 − 6) 65. m + m n + n4 2 24+ 25b 2− 25b 243. 343 + 8a 3 = (7 + 2a )(49 − 14a + 4a 2 ) 1 − 2b 2 + b 4 − 25b 2+ m2 n 2 − m2 n 244. 12a 2bx − 15a 2 by = 3a 2b 4 x − 5 y()= (1 − b 2 ) − 25b 2 2m 4 + 2 m2 n 2 + n 4 − m2 n 2= ( x + 5y)( x − 3y ) = (m2 + n 2 ) − m2 n 2 245. x 2 + 2 xy − 15 y 2= (1 + 5b − b 2 )(1 − 5b − b 2 )46. 6am − 4an − 2n + 3m = (m2 + mn + n 2 )(m2 − mn + n 2 )= (6am + 3m) − (4an + 2n)= 3m (2a + 1) − 2n (2a + 1) 66.c 4 − 4d 4 = (c2 + 2d 2 )(c 2 − 2d 2 )= (3m − 2n)(2a + 1)67. 15x 4 − 15x 3 + 20 x 2 = 5x 2(3x2 − 3x + 4 )− 4b c = (9a + 2bc )(9a − 2bc ) 68. a− x −a− x 6 2 8 3 4 3 4 2247. 81a(48. 16 − 2a + b = 4 + 2a + b 4 − 2a − b) ( 2 )() = (a 2 − x 2 ) − (a + x) = (a + x)(a − x) − (a + x) = (a + x)(a − x − 1)49. 20 − x − x 2 70. 6m + 7m − 2042= − ( x 2 + x − 20)69. x − 8 x − 2404 2 = (6m) 2 2 + 7 (6m2 ) − 120= − ( x + 5)( x − 4) 2404 120 4= ( x + 5)(4 − x ) 60 4 4 ⋅ 5 = 204 ⋅ 3 = 12 30 3 4⋅2 = 850. n 2 + n − 42 = n + 7 n − 6 ( )() 15 535 ⇒ 20 − 12 = 810 5 5⋅ 3 = 1551. a − d + n − c − 2an − 2cd 2 2 2 2 ⇒ 15 − 8 = 7 = ( x 2 − 20)( x 2 + 12) 2 2 1= (a 2 − 2an + n 2 ) − (c 2 + 2cd + d2 )(6m2 + 15)(6m2 − 8) == (a − n) − (c + d ) 13⋅ 2 2 2= (a − n + c + d )(a − n − c − d ) = (2m2 + 5)(3m2 − 4)
• 115. 71. 9n 2 + 4a 2 − 12an ⇒ 9n 2 − 12an + 4a 2 84.a 10 − a 8 + a 6 + a 4 = a 4 (a 6 − a 4 + a 2 + 1) = (3n − 2a )2( ) () (85. 2 x a − 1 − a + 1 = 2 x a − 1 − a − 1 = a − 1 2 x − 1) ()()72. 2 x + 2 = 2 (x + 1)22 ( )( ) ( ) ( )( )) (86. m + n m − n + 3n m − n = m − n m + n + 3n = m − n m + 4n )(() ())((73. 7a x + y − 1 − 3b x + y − 1 = 7a − 3b x + y − 1 ) 87. a 2 − b3 + 2b3 x 2 − 2a 2 x 274. x + 3x − 18 = ( x + 6)( x − 3)2= − (b 3 − 2b3 x 2 ) + (a 2 − 2a 2 x 2 )75. (a + m) − (b + n) = (a + m + b + n )(a + m − b − n )= − b3 (1 − 2 x 2 ) + a 2 (1 − 2 x 2 ) = (1 − 2 x 2 )(a 2 − b 3 )2276 x + 6 x y + 12 xy + 8 y = ( x + 2 y) 3223 32 88. 2am − 3b − c − cm − 3bm + 2a 21 189. x − x + = x − 28a − 22a − 21 = (2am − cm − 3bm) − (3b + c − 2a )9 3277.3= (8a ) − 22 (8a ) − 1682168 4 = m (2a − c − 3b) − (3b + c − 2a ) 90. 4a 2 n − b 4 n42 2 3⋅ 2 = 6= m (2a − 3b − c) + (2a − 3b − c)= (2a n + b2 n )(2a n − b2 n )213 4 ⋅ 7 = 28 = (2a − 3b − c)(m + 1)7 7 ⇒ 28 − 6 = 22 91. 81x − (a + x ) = (9 x + a + x)(9 x − a − x) = (10 x + a)(8 x − a )2(8a − 28)(8a + 6)21 = 4⋅ 2 92. a + 9 − 6a − 16 x 22= (2a − 7)(4a + 3) = (a 2 − 6a + 9) − 16 x 2 = (a − 3) − 16 x 2 = (a − 3 + 4 x )(a − 4 x − 3)278. 1 + 18ab + 81a 2b 2 = 1 + 9ab ( )293. 9a − x − 4 + 4 x2 279. 4a − 1 = (2a + 1)(2a − 1)633 = 9a 2 − ( x 2 − 4 x + 4) = 9a 2 − ( x − 2) = (3a + x − 2)(3a − x + 2) 280. x − 4 x − 4806 394. 9 x 2 − y 2 + 3x − y480 4120 35⋅ 4 = 20 = (9 x 2 − y 2 ) + (3x − y ) = (3x + y )(3x − y ) + (3x − y ) = (3x − y )(3x + y + 1)4 ⋅ 3⋅ 2 = 24401045 ⇒ 24 − 20 = 4(95. x 2 − x − 72 = x − 9 x + 8)() 100. 49 x 2 − 77 x + 30 = (x − 24)( x + 20)96. 36a − 120a b + 49b4 2 24 332 2 = ( 49 x ) − 77 ( 49 x ) + 1. 47021 + 36a 2b2− 36a 2b 21. 470 781. ax − bx + b − a − by + ay 36a 4 − 84a 2b 2 + 49b 4 − 36a 2b2= (ax + ay − a ) − (bx + by − b) 2107 = (6a 2 − 7b 2 ) − 36a 2b 2230 5= a (x + y − 1 ) − b (x + y − 1 )66 7 ⋅ 5 = 35= (a − b)( x + y − 1)= (6a 2 + 6ab − 7b 2 )(6a 2 − 6ab − 7b2 ) 17 ⋅ 6 = 4282 6am − 3m − 2a + 197. a − m − 9n − 6mn + 4ab + 4b 2 22 2 ⇒ 42 + 35 = 77= (6am − 3m) − (2a − 1 ) (49 x − 35)(49 x − 42) = (a 2 + 4ab + 4b 2 ) − (m2 + 6mn + 9n 2) == 3m (2a − 1) − (2a − 1 ) = (3m − 1 )(2a − 1 )7⋅7 = (a + 2b) − (m + 3n)2283. 15 + 14 x − 8 x= (7 x − 5)(7 x − 6) 2= − (8 x 2 − 14 x − 15)= (a + 2b + m + 3n)(a + 2b − m − 3n)[= − (8 x ) − 14 (8 x ) − 1202] 98. 1 −4 8 2 4 2 4a = 1+ a 1− a 101. x − 2abx − 35a b22 2120 4 9 3 3 + 36a 2b 2 − 36a 2b 2303 4 ⋅ 5 = 20 x − 2abx + a 2b2 − 36a 2b 2 2105 3⋅ 2 = 699. 81a8+ 64b12 = ( x − ab) − 36a 2b 222 2⇒ 20 − 6 = 14+ 144a 4b 6 − 144a 4b 6 (8x − 20)(8x + 6) = ( x − ab + 6ab)( x − ab − 6ab)1=−81a 8 + 144a 4b 6 + 64b12 − 144a 4b 6 4⋅2 = ( x + 5ab)( x − 7ab)= − (2 x − 5)(4 x + 3) = (9a 4 + 8b 6 ) − 144a 4b 62= (5 − 2 x )(4 x + 3)= (9a 4 − 12a 2b 3 + 8b 6 )(9a 4 + 12a 2b 3 + 8b 6 )
• 116. () 116. 49a − x − 9 y + 6 xy 3 2 2 2102. 125x 3 − 225x 2 + 135x − 27 = 5x − 3103. (a − 2) − (a + 3) 22 =− [ (x 2− 6xy + 9 y 2 ) − 49a 2 ] = (a − 2 + a + 3)(a − 2 − a − 3) = (2a + 1)(− 5)[= − ( x − 3 y) − 49a 2 2]104. 4a m + 12a n − 5bm − 15bn 2 2= − (7a + x − 3 y )(− 7a + x − 3 y ) = (4a 2 m + 12a 2n) − (5bm + 15bn) = (7a + x − 3 y )(7a − x + 3 y) = 4a 2 (m + 3n) − 5b (m + 3n) = (m + 3n)(4a 2 − 5b) 117. x 4 − y 2 + 4 x 2 + 4 − 4 yz − 4 z 2= ( x 4 + 4 x 2 + 4) − ( y 2 + 4 yz + 4 z 2 )(1+ 3x )105. 1 + 6 x 3 + 9 x 6 =3 2= ( x 2 + 2) − ( y + 2 z ) 22106. a + 3a b − 40b = (a + 8b)(a − 5b) 4 22 2 2= ( x 2 + 2 + y + 2 z)( x 2 + 2 − y − 2 z)107. m + 8a x = (m + 2ax )(m − 2axm + 4a x ) 3 3 322 2 118. a 3 − 64 = (a − 4)(a 2 + 4a + 16)108. 1 − 9 x + 24 xy − 16 ya 5 + x 5 = (a + x )(a 4 − a 3 x + a 2 x 2 − ax 3 + x 4 ) 22 [] 119. = − (9 x 2 − 24 xy + 16 y 2 ) − 1a 6 − 3a 3b − 54b 2 = (a 3 − 9b)(a 3 + 6b) [ = − (3x − 4 y) − 1 ]2120. 121. 165 + 4 x − x 2 [ = − (3x − 4 y + 1)(3x − 4 y − 1) ] = − ( x 2 − 4 x − 165) = (3x − 4 y + 1)(1 + 4 y − 3x )165 53335⋅ 3 = 15109. 1 + 11x + 24 x 2111111⋅ 1 = 11 = ( 24 x ) + 11( 24 x ) + 24 21⇒ 15 − 11 = 4 = (24 x + 8)(24 x + 3)= − ( x − 15)( x + 11) 8⋅ 3= (15 − x ) ( x + 11) = (3x + 1)(8 x + 1) 122. a + a + 1 4 2110. 9 x 2 y 3 − 27 x 3 y 3 − 9 x 5 y 3 = 9 x 2 y 3 (1 − 3x − x 3 )+ a2 − a2 (111. a + b − c 2 2 ) − 9x y 2 22 2 a 4 + 2a 2 + 1 − a 2 = (a 2 + b 2− c + 3xy)(a + b2 − c2 − 3xy)= (a 2 + 1) − a 222 2= (a 2 + a + 1)(a 2 − a + 1) (112. 8 a + 1 − 1 ) 3][ ]x2 y6 x y3 x y3 [ = 2 (a + 1) − 1 4 (a + 1) + 2 (a + 1) + 12 123. − = + − 4 81 2 9 2 9 = (2a + 2 − 1)(4a + 8a + 4 + 2a + 2 + 1) 28 xy y 2 y2 124. 16 x ++ = 4x +2 = (2a + 1)(4a 2 + 10a + 7)5 25 5 125. a b + 4a b − 96 4 42 2113. 100 x y − 121m 4 64 + 100 − 100 = (10 x 2 y 3 + 11m2 )(10 x 2 y 3 − 11m2 )a b + 4a b + 4 − 1004 4 2 2 (114. a + 12 ) + 5(a + 1 ) − 2422= (a 2b 2 + 2) − 1002 = (a + 1 + 8)(a + 1 − 3) = (a 22 2+ 9)(a − 2)2= (a 2b 2 + 2 + 10)(a 2b 2 + 2 − 10)115. 1 + 1. 000 x 6 = (1+ 10x )(1− 10x2 2+ 100 x 4 ) = (a 2b 2 + 12)(a 2b 2 − 8)
• 117. 126. 8a x + 7 y + 21by − 7ay − 8a x + 24a bx23 2= (7 y + 21by − 7ay) + (8a 2 x − 8a 3 x + 24a 2bx) 130.729 − 125x 3 y12 = (9 − 5xy 4 )(81 + 45xy 4 + 25x 2 y 8 )= 7 y (1 + 3b − a ) + 8a 2 x (1 − a + 3b)( ) () ( ) ()( ) 22 131. x + y + x + y = x + y + x + y = x + y x + y + 1= (1 + 3b − a )(7 y + 8a x ) 2 132. 4 − a + b + 2ab 2 2 ()127. x + 11x − 3904 2 4 − a 2 − b 2 + 2ab 390 3130 213⋅ 2 = 26+ b2− b265 5 5⋅ 3 = 15 4 − a2+ 2ab − b 21313 ⇒ 26 − 15 = 11= 4 − (a 2 − 2ab + b 2 )= ( x + 26)( x − 15) = 4 − (a − b)2212128. 7 + 33m − 10m = (2 + a − b)(2 − a + b) 2= − (10m2 − 33m − 7) 2[= − (10m) − 33 (10m) − 70] 133. x − y + x − y 3 3(10m − 35)(10m + 2)= (x 3 − y 3 ) + (x − y )=−5⋅ 2 = (x − y )( x 2 + xy + y 2 ) + ( x − y ) = ( x − y )( x 2 + xy + y 2 + 1)= − (2m − 7)(5m + 1)= (7 − 2m)(5m + 1) 134. a − b + a − b 2 2 3 3129. 4 (a + b) − 9 (c + d )2 2= (a 2 − b 2 ) + (a 3 − b 3 )[ ][= 2(a + b) + 3 (c + d ) 2(a + b) − 3 (c + d )] = (a + b)(a − b) + (a − b)(a 2 + ab + b 2 )= (2a + 2b + 3c + 3d )(2a + 2b − 3c − 3d ) = (a − b)(a + b + a 2 + ab + b 2 )EJERCICIO 107 7. 3ax + 3ay 331. 3ax 2 − 3a12. x 3 − x + x 2 y − y = 3a ( x 2 − 1) = 3a ( x + 1)( x − 1)= 3a ( x + y 3 3 ) = (x 3 − x) + (x 2 y − y)2. 3x 2 − 3x − 6= 3a ( x + y )( x − xy + y 2 2 ) = x (x 2 − 1) + y (x 2 − 1) = 3( x 2 − x − 2) = 3 ( x − 2)( x + 1)8. 4ab − 4abn + an = (x 2 − 1)( x + y ) = (x + 1)(x − 1)( x + y ) 2 2= a (4b − 4bn + n ) = a (2b − n) 2 2 23. 2a x − 4abx + 2b x 2 2 13. 2 a 3 + 6a 2 − 8a = 2 x (a 2 − 2ab + b 2 )9. x − 3x − 4 = 2a (a 2 + 3a − 4) = 2a (a + 4)(a − 1) 4 2 = 2 x (a − b) = 2 x (a − b)(a − b)2= ( x − 4)( x + 1) 2 2 14. 16 x − 48 x y + 36 xy 322= ( x + 2)( x − 2)( x + 1) = 4 x (4 x 2 − 12 xy + 9 y 2 ) = 4 x (2 x − 3 y) 24. 2a 3 − 2 2 = 2 (a 3 − 1) = 2 (a − 1)(a 2 + a + 1)10. a − a − a + 13 2 15. 3x 3 − x 2 y − 3xy 2 + y 35. a − 3a − 28a3 2= (a 3 − a 2 ) − (a − 1)= (3x 3 − x 2 y ) − (3xy 2 − y 3 ) = a (a 2 − 3a − 28) = a (a − 7)(a + 4)= a (a − 1) − (a − 1) = x 2 (3x − y ) − y 2 (3x − y ) 2 = (a − 1)(a − 1) = (3x − y )(x 2 − y 2 ) = (3x − y )( x + y )(x − y ) 26. x − 4 x + x − 43 2 = (x 3 + x 2 ) − (4 x + 4)= (a − 1)(a + 1)(a − 1) 16. 5a 4 + 5a = x ( x + 1) − 4 ( x + 1) 11. 2ax − 4ax + 2a = 5a (a 3 + 1) = 5a (a + 1)(a 2 − a + 1)2 2 = (x − 4)(x + 1) = (x + 2)(x − 2)( x + 1) = 2a ( x 2 − 2 x + 1) = 2a ( x − 1) 22
• 118. 17. 6ax − ax − 2a 27. 4 x 2 + 32 x − 36 2 35. x − 3x 2 − 18 x 3= a (6 x − x − 2)2= 16 x 2 + 32 ( 4 x ) − 144= x (1 − 3x − 18 x 2 )= a (36 x − 6 x − 12) 144 2= − x (18 x 2 + 3x − 1)2 22 = 4a (6 x − 4)(6 x + 3) 722=364 4 ⋅ 3⋅ 3 = 36[= − x (18x ) + 3 (18x) − 182]2⋅3 9 3 ⇒ 36 − 4 = 32− x (18 x + 6)(18 x − 3)= a (3x − 2)(2 x + 1) = 3 3 = (4 x + 36)(4 x − 4)6⋅ 318. n 4 − 81 4= − x (3x + 1)(6x − 1)= (n − 9)(n + 9) = (n + 3)(n − 3)(n + 9) = ( x + 9)(4 x − 4)= x (3x + 1)(1 − 6x )2 2 2119. 8ax 2 − 2a = 4 ( x + 9)( x − 1) 36. 6ax − 2bx + 6ab − 2b= 2a (4 x 2 − 1) = 2a (2 x − 1)(2 x + 1)220. ax 3 + 10ax 2 + 25ax (28. a 4 − a + 2) 2= (6ax − 2bx ) + (6ab − 2b 2 ) = (a + a + 2)(a − a − 2) = 2 x (3a − b) + 2b (3a − b)= ax ( x 2 + 10 x + 25) = ax ( x + 5)( x + 5) 2 2 = (a + a + 2)(a − 2)(a + 1) 2= (3a − b)(2 x + 2b)21. x − 6 x − 7 x 3 2= 2 ( x + b )(3a − b)= x ( x 2 − 6 x − 7)29. x − 25x − 54 6 3 37. am − 7am + 12am= x ( x 2 − 6 x − 7 + 16 − 16) = ( x 3 − 27)(x 3 + 2) 3 2= am (m2 − 7m + 12)= x ( x 2 − 6 x + 9 − 16)= ( x − 3)( x 2 + 3x + 9)( x 3 + 2)= am (m − 4)(m − 3)[= x ( x − 3) − 4 22 ]30. a + a 6 38. 4a x − 4a 2 3 2= x ( x − 3 + 4)( x − 3 − 4) = a (a 5 + 1)= 4a 2 ( x 3 − 1)= x ( x + 1)( x − 7) = a (a + 1)(a 4 − a 3 + a 2 − a + 1)= 4a 2 ( x − 1)( x 2 + x + 1)22. m + 3m − 16m − 48 3231. a b + 2a bx + abx − aby 3 2 2 2= (m3 + 3m2 ) − (16m + 48) 39. 28 x y − 7 xy 3 3 = ab (a + 2ax + x − y 2 2 2 )= 7 xy (4 x 2 − y 2 )= m2 (m + 3) − 16 (m + 3)= (m + 3)(m2 − 16) [ = ab (a + x ) − y 2 2 ]= 7 xy (2 x − y )(2 x + y )= (m + 3)(m − 4)(m + 4)= ab (a + x + y )(a + x − y ) 40. 3abx − 3abx − 18ab 223. x − 6 x y + 12 xy − 8 y 3 2 23 = 3ab ( x 2 − x − 6)32. 3abm − 3ab2= (x − 2 y ) = (x − 2 y )(x − 2 y )( x − 2 y )3 = 3ab (m2 − 1) = 3ab ( x − 3)( x + 2)( )(24. a + b a − b − a − b2 2) ( 2 2)= 3ab (m + 1)(m − 1)41. x 4 − 8 x 2 − 128= (a 2 − b 2 )(a + b − 1)128 433. 81x y + 3xy 4 44 ⋅ 4 = 16= (a + b)(a − b)(a + b − 1) 324 = 3xy (27 x 3 + y 3 )8 4 4⋅ 2 = 825. 32a 5 x − 48a 3bx + 18ab2 x = 3xy (3x + y )(9 x 2 − 3xy + y 2 )2 2 ⇒ 16 − 8 = 8= 2ax (16a 4 − 24a 2b + 9b 2 ) 1= ( x 2 − 16)( x 2 + 8)34. a 4 − a 3 + a − 1= 2ax (4a 2 − 3b) = ( x + 4)( x − 4)( x 2 + 8) 2 = (a 4 − a 3 ) + (a − 1)= 2ax (4a 2 − 3b)(4a 2 − 3b) 42. 18 x y + 60 xy + 50 y 2 2 3 = a 3 (a − 1) + (a − 1)26. x − x + x − x = 2 y (9 x 2 + 30 xy + 25 y 2 )4 3 2 = (a − 1)(a 3 + 1)= x ( x − x + x − 1)3 2= 2 y (3x + 5 y )(3x + 5 y ) = (a − 1)(a + 1)(a 2 − a + 1)[= x x ( x − 1) + (x − 1) = x ( x − 1)(x + 1)2] [ 2]
• 119. ( )(43. x − 2 xy a + 1 + y a + 1 22 ( ) ) ( ) ( )351. 9 x − y − x − y 57. 7 x + 32a x − 15a x62 4 4 2 = (a + 1)( x − 2 xy + y ) = (x − y )[9 ( x − y ) − 1]= x (7 x + 32a x − 15a )2 2 42 2 4 22 = (a + 1)( x − y)( x − y )= (x − y )[3 ( x − y ) + 1] [3 (x − y ) − 1] = x [ (7 x ) + 32a (7 x ) − 105a2 2 22 2 4 ] = (x − y )(3x − 3 y + 1)(3x − 3 y − 1) 105 544. x + 2 x y − 3xy 3 22 5⋅ 7 = 35 = x ( x 2 + 2 xy − 3y 2 ) 21 352. 6a x − 9a − ax3⋅ 1 = 323 2 77 = x ( x + 3 y)( x − y ) = a (6ax − 9a − x2 2)1 ⇒ 35 − 3 = 3245. a x − 4b x + 2a y − 8b y 2 222 = − a (x − 6ax + 9a2 )2x 2 (7 x 2 + 35a 2 )(7 x 2 − 3a 2 )= = (a 2 x − 4b2 x) + (2a 2 y − 8b2 y)= − a (x − 3a )( x − 3a ) 7= x 2 ( x 2 + 5a 2 )(7 x 2 − 3a 2 ) = x (a 2 − 4b2 ) + 2 y (a 2 − 4b 2 )= a (3a − x )( x − 3a ) = (a 2 − 4b2 )( x + 2 y) 2m + 258. x − x 2 y 2n53. 64a − 125a4 = (a − 2b)(a + 2b)(x + 2 y )= ( x m +1 + xy n )( x m +1 − xy n ) = a (64 − 125a 3)= x (x m + y n ) x (x m − y n )46. 45a x − 20a= a (4 − 5a )(16 + 20a + 25a ) 2 422 = x 2 ( x m + y n )( x m − y n ) = 5a 2 (9 x 4 − 4) = 5a 2 (3x 2 + 2)(3x 2 − 2)59. 2 x + 5x − 54 x − 135 4354. 70 x + 26 x − 24 x43 2 = 2 x 2 (35x 2 + 13x − 12)= (2 x 4 − 54 x ) + ( 5x 3 − 135) (47. a 4 − a − 12 ) 2[ = 2 x 2 ( 35x ) + 13 ( 35x ) − 420 ]= 2 x ( x 3 − 27) + 5 ( x 3 − 27) = (a 2 + a − 12)(a 2 − a + 12)2 = ( x 3 − 27)(2 x + 5) = (a + 4)(a − 3)(a 2 − a + 12)420 2 = ( x − 3)( x 2 + 3x + 9)(2 x + 5)210 248. bx − b − x + 1105 52 260. ax 3 + ax 2 y + axy 2 − 2ax 2 − 2axy − 2ay 2 = (bx 2 − x 2 ) − (b − 1) 213 77= a (x 3 + x 2 y + xy 2 − 2 x 2 − 2 xy − 2 y 2 ) = x 2 (b − 1) − (b − 1) [ = a ( x 3 + x 2 y + xy2 ) − (2 x 2 + 2 xy + 2 y 2 ) ]1 = (b − 1)(x 2 − 1) 2 2 ⋅ 7 = 28 = (b − 1)(x + 1)( x − 1) 3⋅ 5 = 15= a [x (x2 + xy + y ) − 2 ( x + xy + y 2 2 2 )]⇒ 28 − 15 = 13 = a (x − 2)( x + xy + y 2 2 )49. 2 x + 6 x − 56 x 4 3 2 (35x + 28)(35x − 15) = 2 x 2 ( x 2 + 3x − 28)=( ) 47 ⋅561. x + y − 1 = 2 x 2 ( x + 7)( x − 4)= 2 x 2 (5x + 4)(7 x − 3)[= (x + y ) + 1 (x + y ) − 12 ][2 ]50. 30a − 55a − 50= ( x + 2 xy + y + 1)(x + y + 1)(x + y − 1) 222= ( 30a ) − 55 ( 30a ) − 1. 500 55. a 7 + 6a 6 − 55a 3 262. 3a 5 + 3a 3 + 3a = a 3 (a 4 + 6a 3 − 55)1. 500 25⋅ 2 = 20= 3a (a 4 + a 2 + 1)2 750 252 ⋅ 3 = 75= a 3 (a 2 + 11)(a 2 − 5) = 3a (a 4 + a 2 + 1 + a 2 − a 2 ) 375 5 755 ⇒ 75 − 20 = 55(30a − 75)(30a + 20) 56. 16a b − 56a b + 49ab[ = 3a (a 4 + 2a 2 + 1 ) − a 2]5 3 3 5 == ab (16a − 56a b + 49b ) 155[]15⋅ 2 4 2 2 4 = 3a (a + 1 ) − a2 = (2a − 5)(15a + 10) 2 2= ab (4a 2 − 7b 2 ) 3 3 2 1 = 5 (2a − 5)(3a + 2)= 3a (a + a + 1 )(a − a + 1 )22
• 120. EJERCICIO 108 9. 9 x 4 + 9 x 3 y − x 2 − xy1. 1 − a8= (9 x 4 + 9 x 3 y ) − ( x 2 + xy) 16 a − 25a + 1444 2 = (1+ a 4 )(1− a 4 )= 9 x 3 (x + y) − x (x + y) 144 44 2 = 16 = (1+ a 4 )(1+ a 2 )(1 − a 2 )364 = (9 x 3 − x )( x + y) 9 332 = 9 = (1+ a 4 )(1+ a )(1+ a)(1− a) 2 = x (9 x − 1)( x + y )23 3 ⇒ 16 + 9 = 252. a − 1 = x (3x + 1)(3x − 1)( x + y )61 = (a 3 + 1)(a 3 − 1) 10. 12ax + 33ax − 9a42= (a 2 − 16 )(a 2 − 9 ) = (a + 1) (a 2 − a + 1)(a − 1)(a 2 + a + 1) = 3a (4 x 4 + 11x 2 − 3) = (a + 4)(a − 4)(a + 3)(a − 3)3. x − 41x + 400 [ = 3a (4 x 2 ) + 11(4 x 2 ) − 12] 4 217. a x − a y + 2ax − 2ay 22 3 2 33 3 = (a 2 x 3 − a 2 y 3 ) + (2ax 3 − 2ay 3 ) 400 4 100 5 42 = 16 3a (4 x 2 + 12)(4 x 2 − 1) = 4 = a 2 ( x 3 − y 3 ) + 2a ( x 3 − y 3 ) 20552 = 25 4 4 ⇒ 25 + 16 = 41= 3a(x 2 + 3)(4 x 2 − 1)= (a 2 + 2a )( x 3 − y 3 ) 1 = ( x 2 − 25)( x 2 − 16)= 3a (x 2 + 3)(2 x + 1)(2 x − 1)= a (a + 2)( x − y )( x 2 + xy + y 2 )= ( x + 5)( x − 5)( x + 4)( x − 4) 11. x − y8818. a + 2a − a − 2a 43 24. a − 2a b + b 4= (x + y )(x − y )= (a 4 + 2a 3 ) − (a 2 + 2a) 4 2 2 4 4 4 4 = (a − b )2 2 2 = (x + y ) (x + y )( x − y ) 4 4 2 2 22 = a 3 (a + 2) − a (a + 2) = [(a + b)(a − b)] = (a + b) (a − b)= (x + y )( x + y )( x + y )( x − y ) = (a 3 − a )(a + 2) 2 224 4 2 2 12. x − 7 x − 8 = a (a 2 − 1)(a + 2)635. x + x − 2 x 5 3 = x ( x 4 + x 2 − 2) = (x − 8)(x + 1)33 = a (a + 1)(a − 1)(a + 2) = x (x + 2)( x − 1) 2 2= (x − 2)( x + 2 x + 4)( x + 1) 2 319. 1 − 2a 3 + a 6 = x (x + 2)(x + 1)( x − 1) = (x − 2)( x + 2 x + 4)( x + 1)(x − x + 1) 2 2 = (a 3 − 1) 22 13. 64 − x66. 2 x + 6 x − 2 x − 6 4 3[ = (a − 1)(a 2 + a + 1)] 2 = (2 x + 6x ) − (2 x + 6) 4 3= (8 + x 3 )(8 − x 3 )= (2 + x )(4 − 2 x + x 2 )(2 − x )(4 + 2 x + x 2 ) = (a − 1) (a 2 + a + 1)22 = 2 x 3 ( x + 3) − 2 ( x + 3) = (2 x 3 − 2)( x + 3) 14. a − a b − a b + b 20. m − 7295 3 22 3 56 = 2 ( x 3 − 1)( x + 3) = (a − a b ) − (a b − b53 2 2 3 5 )= (m2 − 9)(m4 + 9m2 + 81) = 2 ( x − 1)( x 2 + x + 1)( x + 3) = a 3 (a 2 − b 2 ) − b 3 (a 2 − b2 )= (m + 3)(m − 3)(m4 + 9m2 + 81 + 9m2 − 9m2 )7. 3x 4 − 243 = (a 2 − b 2 )(a 3 − b 3 )[= (m + 3)(m − 3) (m4 + 18m2 + 81) − 9m2] = 3( x − 81)4= (a + b)(a − b)(a − b)(a + ab + b 2 2 ) = (m + 3)(m − 3)[(m + 9) − 9m ]2 22 = 3( x + 9)(x − 9) 2 2 15. 8 x 4 + 6 x 2 − 2 = (m + 3)(m − 3)(m + 3m + 9)(m − 3m + 9)22 = 3( x + 9)( x + 3)( x − 3) 2= 2 (4 x + 3x − 1)4221. x − x58. 16 x − 8 x y + y 4 2 2 4= 2 (4 x[2 2 ) + 3 (4 x ) − 42 ] = x (x 4 − 1) = (4 x − y) 2 22 (4 x 2 + 4)(4 x 2 − 1) 2 = x (x 2 + 1)(x 2 − 1)= = [(2 x + y )(2 x − y )] 2 = x (x 2 + 1)(x + 1)(x − 1) 4 = (2 x + y )(2 x − y )(2 x + y )(2 x − y ) = 2 ( x 2 + 1)(4 x 2 − 1) = 2 (x 2 + 1)(2 x + 1)(2 x − 1)
• 121. 22. x 5 − x 3 y 2 + x 2 y 3 − y 533. 16m − 25m + 9 42 27.1 − a b 6 6= (x 5 − x 3 y 2 ) + ( x 2 y 3 − y 5 )= (1 − a 3b 3 )(1 + a 3b 3 ) = (16m ) − 25(16m2 ) + 1442 2= x 3 (x 2 − y 2 ) + y 3 (x 2 − y 2 ) = (1 − ab)(1 + ab + a 2b 2 )(1 + a 3b 3 ) 1444 36 44 2 = 16= (x + y 3 3 )(x 2 −y 2) = (1 − ab)(1 + ab + a 2b 2 )(1 + ab)(1− ab + a 2b 2 )9332 = 9= (x + y )(x 2 − xy + y 2 )(x + y)( x − y) 33 ⇒ 16 + 9 = 2528. 5ax + 10ax − 5ax − 10a 32 123. a b − a b − a b + ab = (5ax 3 + 10ax 2 ) − (5ax + 10a ) (16m− 16)(16m2 − 9) 4 3 2 2 3 42== (a b − a b ) − (a b − ab 4 3 2 2 3 4 ) = 5ax 2 ( x + 2) − 5a ( x + 2) 16= (m2 − 1)(16m2 − 9)= a b (a − b) − ab (a − b) 3 3 = (5ax 2 − 5a )( x + 2)= (m + 1)(m − 1)(4m + 3)(4m − 3)= (a 3b − ab 3 )(a − b)= 5a ( x 2 − 1)(x + 2)34. 3abx 2 − 12 ab + 3bx 2 − 12b= ab (a 2 − b 2 )(a − b) = 5a ( x + 1)( x − 1)( x + 2)= (3abx 2 + 3bx 2 ) − (12ab + 12b)= ab (a + b)(a − b)(a − b)= 3bx 2 (a + 1) − 12b (a + 1)29. a x + b y − b x − a y= (3bx 2 − 12b)(a + 1) 2 2 2 2 2 2 2 224. 5a − 3.125 4= 5 (a 4 − 625) = (a x − b x ) + (b y − a y 2 2 2 2 2 2 2 2 )= 3b ( x 2 − 4)(a + 1)= 5 (a 2 + 25)(a 2 − 25)= x (a − b ) + y (b − a ) = 3b ( x + 2)( x − 2)(a + 1) 2 2 2 2 2 2= 5 (a + 25)(a + 5)(a − 5) 2= x (a − b ) − y (a − b ) 2 2 2 2 2 2 35. 3a m + 9am − 30m + 3a + 9a − 302 2= (a − b )( x − y ) 2 2 2 2 = (3a 2 m + 9am − 30m) + (3a 2 + 9a − 30)(25. a + 2a2 ) 2 − 2 (a + 2a ) − 3 2= (a + b)(a − b)( x + y )( x − y ) = 3m (a 2 + 3a − 10) + 3 (a 2 + 3a − 10)= (a + 2a ) − 2 (a + 2a ) − 3 + 4 − 4= (3m + 3)(a 2 + 3a − 10) 2 2 2{[(a + 2a) − 2 (a + 2a)+ 1]− 4} 30. x + x − 2= 3 (m + 1)(a + 5)(a − 2) 2 8 4=2 2 = (x + 2)(x − 1 ) 4 4 36. a x − 5a x + 6a + x − 5x + 63 233 2= (a 2 + 2a − 1) − 4 2 = (x 4 + 2)( x 2 + 1)( x 2 − 1) = (a 3 x 2 − 5a 3 x + 6a 3 ) + ( x 2 − 5x + 6)= (a 2 + 2a − 1 + 2)(a 2 + 2a − 1 − 2) = (x 4 + 2)( x 2 + 1)( x + 1)( x − 1) = a 3 ( x 2 − 5x + 6) + ( x 2 − 5x + 6)= (a 2 + 2a + 1)(a 2 + 2a − 3) = (a 3 + 1)( x 2 − 5x + 6)= (a + 1) (a + 2a − 3 + 4 − 4) = (a + 1)(a 2 − a + 1)(x − 3)( x − 2) 2 31. a + a − 9a − 9a 2 4 3 2 = (a + a ) − (9a + 9a )= (a + 1)[(a + 2a + 1) − 4 ]() ()() 2 4 3 2 37. x x − y − 2 x − 1 x − y 22 2 2 22 = a (a + 1) − 9a (a + 1) [(a + 1) − 4] )[x − (2 x − 1) ] = (x − y 3= (a + 1) 2 2222 = (a 3 − 9a )(a + 1)= ( x + y)( x − y)( x − 2 x + 1)= (a + 1) (a + 1 + 2) (a + 1 − 2)2 2= a (a − 9)(a + 1) 2= ( x + y)( x − y)( x − 1) 2= (a + 1) (a + 3)(a − 1)= a(a + 3)(a − 3)(a + 1) 238. a ( x + 1) + 3ax ( x + 1) 326. a x + 2ax − 8a − 16a= a ( x + 1)(x − x + 1) + 3ax ( x + 1)2 33 22 32. a x + a x − 6a − x − x + 6 2 2 2 2 2= (a x + 2ax ) − (8a + 16a ) 2 3 3 2= (x + 1)[a (x − x + 1) + 3ax ] = (a x + a x − 6a ) − ( x + x − 6)2 2 2 2 2 2= ax (a + 2) − 8a (a + 2) 3= (x + 1)(ax − ax + a + 3ax ) = a ( x + x − 6) − ( x + x − 6)2 2 2 2= (ax − 8a )(a + 2) 3= (x + 1)(ax + 2ax + a ) = (a − 1)( x + x − 6)2 2 2= a ( x − 8)(a + 2) 3= a ( x + 1)(x + 2 x + 1) = (a + 1)(a − 1)( x + 3)( x − 2)2= a ( x − 2)(x 2 + 2 x + 4)(a + 2)= a ( x + 1)(x + 1) = a (x + 1)2 3
• 122. EJERCICIO 109 6. 2a − 2a − 4a − 2a b + 2ab + 4b 4322 2 2 210. x + x − 81x − 817 4 3 = (2a 4 − 2a 3 − 4a 2 ) − (2a 2b 2 − 2ab 2 − 4b 2 )= (x 7 + x 4 ) − (81x 3 + 81)1. x − xy = x 4 ( x 3 + 1) − 81(x 3 + 1)9 8 = 2a 2 (a 2 − a − 2) − 2b 2 (a 2 − a − 2) = x (x − y ) = (x 4 − 81)(x 3 + 1)8 8 = 2 (a − a − 2)(a − b )2 2 2 = x (x − y )( x + y )= (x 2 + 9)(x 2 − 9)( x + 1)(x 2 − x + 1)4 4 4 4 = 2 (a − 2)(a + 1)(a + b)(a − b) = x(x + y )(x − y )(x + y )2 2 2 2 4 4= (x 2 + 9)(x + 3)(x − 3)(x + 1)( x 2 − x + 1) = x (x + y )(x + y )( x − y )( x + y )2 2 4 411. x − x 177. x + 5x − 81x − 405x = x ( x16 − 1)65 22. x − 40 x + 144 x5 3 = ( x + 5x ) − (81x + 405x) = x ( x 4 − 40 x 2 + 144)6 5 2 = x ( x 8 + 1)(x 8 − 1) = x 5 (x + 5) − 81x ( x + 5) = x ( x 2 − 36)( x 2 − 4) = x ( x 8 + 1)(x 4 + 1)(x 4 − 1) = x ( x − 6)( x + 6)( x + 2 )( x − 2 )= ( x 5 − 81x )( x + 5) = x ( x 8 + 1)(x 4 + 1)(x 2 + 1)(x 2 − 1) = x ( x 4 − 81)( x + 5)3. a + a b − a − ab = x ( x 8 + 1)(x 4 + 1)(x 2 + 1)(x + 1)(x − 1) = x ( x 2 − 9)( x 2 + 9)( x + 5)6 3 3 4 3 = (a 6 + a 3b3 ) − (a 4 + ab3 )12. 3x − 75x − 48 x + 1. 2006 42 = x ( x + 3)( x − 3)( x 2 + 9)( x + 5) = a 3 (a 3 + b 3 ) − a (a 3 + b3 )= (3x 6 − 75x 4 ) − (48 x 2 − 1. 200) = (a 3 − a)(a 3 + b3 )= 3x 4 ( x 2 − 25) − 48 ( x 2 − 25)8. 3 − 3a 6 = a (a 2 − 1)(a + b)(a 2 − ab + b 2 ) = (3x 4 − 48)( x 2 − 25)= 3 (1 − a 6 ) = a (a + 1)(a − 1)(a + b)(a 2 − ab + b2 ) = 3( x 4 − 16)( x + 5)( x − 5)= 3 (1 − a 3 )(1 + a 3 ) = 3( x 2 + 4)( x 2 − 4)( x + 5)( x − 5)= 3 (1 − a )(1 + a + a 2 )(1 + a )(1 − a + a 2 )4. 4 x − 8 x + 4 = 3( x 2 + 4)( x + 2)( x − 2)(x + 5)( x − 5)4 2 = 4 ( x − 2 x + 1) 9. 4ax (a − 2ax + x ) − a + 2a x − ax4 2 22 2 32 2 13. a x − x + a x − x6 2 2 6 = 4 ( x − 1)( x − 1)= 4ax 2 (a − x ) − a (a 2 − 2ax + x 2 )2= (a 6 x 2 − x 2 ) + (a 6 x − x )2 2 = 4 ( x + 1) ( x − 1) = 4ax (a − x ) − a (a − x )2 2
• Volar
|
__label__pos
| 1 |
getButterfly
Resume
Promises in JavaScript
Writing code in an async programming framework like node.js becomes super complex and unbearably ugly super fast. You are dealing with synchronous and asynchronous functions and mixing them together can get really tricky. That is why we have Control Flow.
From Wikipedia,
In computer science, control flow (or alternatively, flow of control) refers to the order in which the individual statements, instructions, or function calls of an imperative or a declarative program are executed or evaluated.
Basically, control flow libraries allow you to write non-blocking code that executes in an asynchronous fashion without writing too much glue or plumbing code. There is a whole section on control-flow modules to help you unwind the spaghetti of callbacks that you will quickly land yourself into while dealing with async calls in node.js.
Control flow as a pattern can been implemented via several approaches and one of such approaches is called Promises.
First things first, Promises is not a new language feature of JavaScript. Nothing has fundamentally changed in the language itself to support Promises. They could have been easily implemented 5 years back as well (and probably were). Promises is a pattern to solve the traditional callback hell problem in the async land. There are other similar approaches to solve the same problem as well.
The reason why people are talking about Promises and other similar patterns now is partly because of two reasons in my opinion:
1. 5 years back, the web was much simpler. The amount of complex, JavaScript based, front-end heavy web apps dealing with several asynchronous calls simultaneously were few and far between. In many ways, there was no general need for a pattern like Promises.
2. The second reason in my opinion is node.js. Thanks to node.js, people are now writing all the backend code in async fashion, backend code where all the heavylifting is done to generate the right response from a multitude of data sources. All these data sources are queried in async fashion in node.js and there is an urgent need of control flow to manage concurrency.
Because of the above two reasons, a lot of frameworks have started providing the concept of Promises out of the box. CommonJS has realized that the pattern needs to be standardized across these various frameworks and has a spec now, http://wiki.commonjs.org/wiki/Promises
Ok, so now that it’s clear that Promises is a pattern, what exactly is it and how is it different from other traditional approaches?
From Wikipedia,
In computer science, futurepromise, and delay refer to constructs used for synchronization in some concurrent programming languages. They describe an object that acts as a proxy for a result that is initially not known, usually because the computation of its value has not yet completed.
Yep, that’s nice in theory but in practice, this is what changes:
asyncCall(data, function(response) {
// You have response from your asynchronous call here
}, function(err) {
// if the async call fails, the error callback is invoked
});
// And now with Promises pattern, you would write it like this:
var promise = asyncCall(data);
promise.done(function(response) {
// You have response from your asynchronous call here
}).fail(function(err) {
// if the async call fails, you have the error response here.
});
Looks almost the same thing. In fact, it looks like Promises can hide the true nature of a function. With Promises, it can be super hard to tell if a call is synchronous or asynchronous. I say so because this is how your JSDoc for your async call function would change.
/**
* asynchronousCall function
* @param data - input data
* @param success callback. Should accept `response` parameter
* @param failure callback. Should accept `error` parameter
* @return void
*/
to
/**
* asynchronousCall function
* @param data - input data
* @return promise object- It will resolve with `response` data
* or fail with `error` object
*/
Some people will argue second style is cleaner. I am more in favour with the first style on this one.
If you are a small scrappy startup with fast growing codebase, it’s really hard to have proper documentation. In such scenarios where proper documentation is missing, Promises are a deal breaker for me as more than once, you will have to look within a function just to understand how to consume it and whether its asynchronous or not. With the first style, the function definition is very explicit and usage doesn’t rely heavily on the documentation. If there is a callback, it most likely is asynchronous.
Having said that, there are some pros in the Promises approach.
The first one that is usually talked about is how Promises are good for dealing with a multitude of async/sync calls. Taming multiple async calls becomes much easier with Promises.
Imagine a typical scenario where one has to perform something only after a list of tasks are done. These tasks can be both asynchronous or synchronous in nature in themselves. With Promises, one can write code that functions identically calling these synchronous and asynchronous functions, without getting into the nested callback hell that might otherwise happen.
var fn = function() {
var dfd = new Deferred();
var promises = [];
promises.push(async1()); // an async operation
promises.push(async2()); // an async operation
promises.push(sync1()); // a sync operation
promises.push(async3()); // an async operation
// You want to perform some computation after above 4 tasks are done
Promise.when(promises).done(function() {
for (var i = 0, len = arguments.length; i < len; i++) {
if (!arguments[i]) {
dfd.resolve(false);
}
}
dfd.resolve(true);
}).fail(function(err) {
dfd.reject(err);
});
return dfd.promise();
};
This function returns a promise, based on the results of a bunch of tasks. These tasks are a mix of async and sync calls. Notice how in the code, It does not have to distinguish between those calls. This is a huge benefit to most of the Promises implementations.
Typically, all Control-flow libraries following other patterns also provide this benefit though. An example is async module in node.js modules. After all, this is the entire reason behind control-flow. The difference between Promises based implementations vs callback based implementations is subtle and more a matter of choice than anything else.
Another advantage that is given to Promises based implementations is how they are helpful in attaching multiple callbacks for an async operation. With Promises, you can attach listeners to an async operation via done even after the async call has completed. If attached after completion, that callback is immediately invoked with the response.
Traditionally, we have been solving this problem using Events. An event is dispatched when an async task completes and all those who care, can subscribe to the event prior and execute on it when the event happens. The typical problem with Events though is that you have to subscribe early else you can miss an event.
var t1 = Event.subscribe('asyncOp', function(data) {
// Listener for the data that comes in when the event happens
});
async(data, function(response) {
Event.dispatch('asyncOp', response);
});
var t2 = Event.subscribe('asyncOp',function(data) {
// Listener for the data that comes in when the event happens
// This might never fire if we subscribe after the event already fired
});
With Promises, you can attach those callbacks at any point of time without caring if the call is already complete or not.
var p = async(data);
p.done(function(response) {
// do task 1
});
p.done(function(response) {
// do task 2
});
The second gist is definitely cleaner and helps in structuring your code better. You don’t have to bother about subscribing early too.
This is more of a clear win for the Promises based approach in my book. As I said, you can solve the same problem with an Event based approach as well but designing an Event registry just to solve the issue of multiple callbacks would be an overkill. Events by nature bring more to the table like propagation, default behavior etc. If your app requires them for better reasons, use them by all means for multiple callbacks too. They provide a viable solution. However, if you are trying to solve just the issue of multiple callbacks, Promises do it pretty well.
To summarize my thoughts, I think Promises are a nice pattern but nothing too special. Similar functionality can be mocked in other approaches too. However, if you decide to use a Promises implementation, make sure you are strictly documenting your code as otherwise it becomes an organizational problem to bring new developers on board with your codebase.
Reference: https://github.com/wolffe/Promises
Find more JavaScript tutorials, code snippets and samples here or more jQuery tutorials, code snippets and samples here.
Leave a Reply
|
__label__pos
| 0.744952 |
Adware
0 Comment
News-wucugi.cc virus: everything you need to know about this computer threat
News-wucugi.cc is an URL which do not exist. No matter how trustworthy-looking ads it displays, all what it seeks is to make you install questionable programs on the system. This adware is compatible with all popular browsers on the market (Google Chrome, Mozilla Firefox, and Internet Explorer); However, you should check your computer with a reputable anti-spyware as soon as they start appearing on your screen because News-wucugi.cc pop-up virus is closely related to an adware-type program, which is most probably hiding in your computer. however, you should keep in mind that the removal of those News-wucugi.cc might reduce the possibility to infect the system with different kinds of undesirable applications. fun feature, you should think twice before installing this program on your computer because it has been noticed that it is capable of initiating not only these activities. therefore, whenever you decide to install a freeware on your computer, make sure that you check it for ‘optional downloads’.
Download Removal Toolto remove News-wucugi.cc
* WiperSoft scanner, available at this website, only works as a tool for virus detection. To have WiperSoft in its full capacity, to use removal functionality, it is necessary to acquire its full version. In case you want to uninstall WiperSoft, click here.
News-wucugi.cc comes in a bundle with many freeware that are downloaded from the Internet. Start today to walk a new way to see your series and movies as you’ve always wanted.” Although its sounds like this program can be beneficial for you, you should not believe what this program says about itself. The worst part is that it collects information about your online activity and it can even reach your passwords and other sensitive information. Since we cannot clearly distinguish which advertising-supported software is residing in your device and generating News-wucugi.cc, the best solution would definitely be to run a full security scan with an anti-malware tool.
How News-wucugi.cc infiltrates computers?
This adware may infiltrate your computer suspiciously and resemble a virus at first. Please, pay more attention to freeware’s installation if you want to avoid such downloads on your computer! travels bundled with freewares and sharewares, such as various download managers, toolbars, video converters and so on. Not to mention, News-wucugi.cc pop-up ads may also redirect you to questionable websites, which may be filled with viruses or questionable programs. You will be forced to endure the slower than usual performance of your computer. If you have little competence in the field, you should better choose the automatic News-wucugi.cc removal method instead.
It is definitely not worth keeping News-wucugi.cc installed on your system. It does not mean that Bing has anything to do with News-wucugi.cc. To avoid such dangerous instance make sure to run an in-depth analysis of your operating system for potential leftovers of this adware. As mentioned before, Crossrider programs can be deleted manually, which is why we have produced the instructions below. In fact, it is possible that you will be presented with potentially harmful web content. In the expanded setup window, untick the statements that claim you agree to install additional freeware. Deselect the tick marks next to such proposals to refuse to install them.
How to remove News-wucugi.cc ads?
Most of the time, it is possible to uninstall News-wucugi.cc and other similar apps manually via Control Panel, but some of the files might remain. If News-wucugi.cc causes specific security issues, it is obvious that you have to get rid of it. The problem with these free offers is that they do not indicate that various additional programs may be brought to your computer’s system. But keep in mind that manual removal might not always do the trick. as it might be your system got infected with viruses while having it. And, this is why the new versions of Mozilla Firefox may block this browser extension. If you manage to complete all steps correctly, you will be able to eliminate
Download Removal Toolto remove News-wucugi.cc
* WiperSoft scanner, available at this website, only works as a tool for virus detection. To have WiperSoft in its full capacity, to use removal functionality, it is necessary to acquire its full version. In case you want to uninstall WiperSoft, click here.
Learn how to remove News-wucugi.cc from your computer
Step 1. Uninstall News-wucugi.cc
a) Windows 7/XP
1. Start icon → Control Panel win7-start How to remove News-wucugi.cc?
2. Select Programs and Features. win7-control-panel How to remove News-wucugi.cc?
3. Uninstall unwanted programs win7-uninstall-program How to remove News-wucugi.cc?
b) Windows 8/8.1
1. Right-click on Start, and pick Control Panel. win8-start How to remove News-wucugi.cc?
2. Click Programs and Features, and uninstall unwanted programs. win8-remove-program How to remove News-wucugi.cc?
c) Windows 10
1. Start menu → Search (the magnifying glass).
2. Type in Control Panel and press it.win10-start How to remove News-wucugi.cc?
3. Select Programs and Features, and uninstall unwanted programs. win10-remove-program How to remove News-wucugi.cc?
d) Mac OS X
1. Finder → Applications.
2. Find the programs you want to remove, click on them, and drag them to the trash icon.mac-os-app-remove How to remove News-wucugi.cc?
3. Alternatively, you can right-click on the program and select Move to Trash.
4. Empty Trash by right-clicking on the icon and selecting Empty Trash.
Step 2. Delete [postname[ from Internet Explorer
1. Gear icon → Manage add-ons → Toolbars and Extensions. IE-gear How to remove News-wucugi.cc?
2. Disable all unwanted extensions. IE-add-ons How to remove News-wucugi.cc?
a) Change Internet Explorer homepage
1. Gear icon → Internet Options. ie-settings How to remove News-wucugi.cc?
2. Enter the URL of your new homepage instead of the malicious one. IE-settings2 How to remove News-wucugi.cc?
b) Reset Internet Explorer
1. Gear icon → Internet Options.
2. Select the Advanced tab and press Reset. ie-settings-advanced How to remove News-wucugi.cc?
3. Check the box next to Delete personal settings. IE-reset How to remove News-wucugi.cc?
4. Press Reset.
Step 3. Remove News-wucugi.cc from Microsoft Edge
a) Reset Microsoft Edge (Method 1)
1. Launch Microsoft Edge → More (the three dots top right) → Settings. edge-settings How to remove News-wucugi.cc?
2. Press Choose what to clear, check the boxes and press Clear. edge-clear-data How to remove News-wucugi.cc?
3. Ctrl + Alt + Delete together.
4. Task Manager → Processes tab.
5. Find Microsoft Edge process, right-click on it, choose Go to details. task-manager How to remove News-wucugi.cc?
6. If Go to details is not available, choose More details.
7. Locate all Microsoft Edge processes, right-click on them and choose End task.
b) (Method 2)
We recommend backing up your data before you proceed.
1. Go to C:\Users\%username%\AppData\Local\Packages\Microsoft.MicrosoftEdge_8wekyb3d8bbwe and delete all folders. edge-folder How to remove News-wucugi.cc?
2. Start → Search → Type in Windows PowerShell. edge-powershell How to remove News-wucugi.cc?
3. Right-click on the result, choose Run as administrator.
4. In Administrator: Windows PowerShell, paste this: Get-AppXPackage -AllUsers -Name Microsoft.MicrosoftEdge | Foreach {Add-AppxPackage -DisableDevelopmentMode -Register $($_.InstallLocation)\AppXManifest.xml -Verbose} below PS C:\WINDOWS\system32> and press Enter. edge-powershell-script How to remove News-wucugi.cc?
Step 4. Delete [postname[ from Google Chrome
1. Menu → More tools → Extensions. chrome-menu-extensions How to remove News-wucugi.cc?
2. Delete all unwanted extensions by pressing the trash icon. chrome-extensions-delete How to remove News-wucugi.cc?
a) Change Google Chrome homepage
1. Menu → Settings → On startup. chrome-menu How to remove News-wucugi.cc?
2. Manage start up pages → Open a specific page or set of pages. chrome-startup-page How to remove News-wucugi.cc?
3. Select Add a new page, and type in the URL of the homepage you want.
4. Press Add.
5. Settings → Search engine → Manage search engines. chrome-search-engines How to remove News-wucugi.cc?
6. You will see three dots next to the set search engine. Press that and then Edit.
7. Type in the URL of your preferred search engine, and click Save.
b) Reset Google Chrome
1. Menu → Settings. chrome-menu How to remove News-wucugi.cc?
2. Scroll down to and press Advanced. chrome-settings How to remove News-wucugi.cc?
3. Scroll down further to the Reset option.
4. Press Reset, and Reset again in the confirmation window. chrome-reset How to remove News-wucugi.cc?
Step 5. Delete [postname[ from Mozilla Firefox
1. Menu → Add-ons → Extensions. mozilla-menu How to remove News-wucugi.cc?
2. Delete all unwanted extensions. mozilla-extensions How to remove News-wucugi.cc?
a) Change Mozilla Firefox homepage
1. Menu → Options. mozilla-menu How to remove News-wucugi.cc?
2. In the homepage field, put in your preferred homepage. mozilla-options How to remove News-wucugi.cc?
b) Reset Mozilla Firefox
1. Menu → Help menu (the question mark at the bottom). mozilla-troubleshooting How to remove News-wucugi.cc?
2. Press Troubleshooting Information.
3. Press on Refresh Firefox, and confirm your choice. mozilla-reset How to remove News-wucugi.cc?
Step 6. Delete [postname[ from Safari (Mac)
1. Open Safari → Safari (top of the screen) → Preferences. safari-menu How to remove News-wucugi.cc?
2. Choose Extensions, locate and delete all unwanted extensions. safari-extensions How to remove News-wucugi.cc?
a) Change Safari homepage
1. Open Safari → Safari (top of the screen) → Preferences. safari-menu How to remove News-wucugi.cc?
2. In the General tab, put in the URL of the site you want as your homepage.
b) Reset Safari
1. Open Safari → Safari (top of the screen) → Clear History.
2. Select from which time period you want to delete the history, and press Clear History.safari-clear-history How to remove News-wucugi.cc?
3. Safari → Preferences → Advanced tab.
4. Check the box next to Show Develop menu. safari-advanced How to remove News-wucugi.cc?
5. Press Develop (it will appear at the top) and then Empty Caches.
If the problem still persists, you will have to obtain anti-spyware software and delete News-wucugi.cc with it.
Disclaimer
This site provides reliable information about the latest computer security threats including spyware, adware, browser hijackers, Trojans and other malicious software. We do NOT host or promote any malware (malicious software). We just want to draw your attention to the latest viruses, infections and other malware-related issues. The mission of this blog is to inform people about already existing and newly discovered security threats and to provide assistance in resolving computer problems caused by malware.
add a comment
|
__label__pos
| 0.736619 |
Take the 2-minute tour ×
MathOverflow is a question and answer site for professional mathematicians. It's 100% free, no registration required.
I have a system of nonlinear algebraic equations which I'm wanting to solve numerically (for example with a Newton iteration based technique). I can formulate this either as the single system of size N:
f( x ) = 0
or as the nested systems of size P, Q:
g( y, z) = 0,
h( z ) = 0.
It may be that P+Q < N (ie, the nested problem reduces the size of my system to solve).
Is it known which approach is more computationally efficient?
share|improve this question
3
You're kinda low on the detail level. "solve $f(x)=0$, with $f$ nonlinear" could easily describe 90% of the world's problems. – Federico Poloni Jun 9 '11 at 14:02
What is the nature of this decomposition? Do $h(z)$ and $g(y,z)$ have any special properties (linearity, etc.)? – Gilead Jun 9 '11 at 21:14
I think the key word that I missed was algebraic, and the example of Newton iteration. The particular applications are generalizations of the implicit algorithm described in section 9.2 of <a href="relativity.livingreviews.org/Articles/lrr-2003-7/">this review</a>. In particular, they involve a multi-dimensional implicit root-find for ${\bf x}$. There's two cases that I'm interested in; one will convert the 2d root-find for ${\bf x}$ into a pair of nested 1d root-finds. The other converts a 4d root find into a 2d nested within a 1d. I can't see any particular special properties. – Ian Jun 10 '11 at 7:40
1 Answer 1
There's a third option I'd consider: alternated iterations. Namely, call $N[p]$ the Newton iteration for a function $p(x)$, and solve $$ z_{k+1}=N[h](z_k) $$ $$ y_{k+1}=N[g(\cdot,z_{k+1})](y_k) $$ ` (I hope the notation is understandable).
Typically this kind of ideas get you slightly better results than vanilla Newton, since the updated $z_{k+1}$ is used "as soon as it's available". I do not have specific information or references to this approach for this exact problem though. Give it a try maybe and see if it works.
share|improve this answer
Thanks; I'm mainly using black boxes for the root finding, so this may take a while to check. – Ian Jun 10 '11 at 14:19
Your Answer
discard
By posting your answer, you agree to the privacy policy and terms of service.
Not the answer you're looking for? Browse other questions tagged or ask your own question.
|
__label__pos
| 0.752841 |
How Long Do Idiots Live? TikTok Trends and Google Meme Elucidated
on
|
views
and
comments
While Google is one of the most reliable sources of information, sometimes, you can get funny results from this popular search engine. People trolling funny Google results is not a new thing. On TikTok, people often make fun of weird Google results. How long do idiots live is one such TikTok trend among many that have become very popular in recent times.
On TikTok, users ask many unusual questions and insist others search for the results on Google. What becomes more exciting is that the Google results of those questions are absolutely funny. The “How long do idiots live” trend became popular in 2021 on TikTok and other social media platforms and then it reappeared with a new version and became even more popular. Here’s everything to know about this trend and other similar Google memes.
How Does the “How Long Do Idiots Live” Joke Become a Trend?
The origin of the “How Long Do Idiots Live” joke is the “How Old Is X” joke. A Reddit user posted a meme on 3rd February 2017, presenting the funny Google results for How old are Knuckles from Sonic? Google showed the lifespan of echidnas which implied that Knuckle would be celebrating his last birthday in 2017. Since then, Internet users started to extend this joke in different areas.
In 2021, a TikTok user posted a meme displaying the Google results for “How Long Do Idiots Live?” Google’s result for this question is 12 to 15 years. This can be interpreted in a way that all kids are fools and idiots. By the time they will become adults, they will become intelligent and more mature.
With this funny Google result, TikTok users started to make fun of each other by posting the “How Long Do Idiots Live” meme and this went viral immediately in 2021. However, this reappeared in 2022 as a new trend with the following phrase, “I’ll never forget you”.
I’ll Never Forget You: The New Version
“I’ll Never Forget You” is a popular song by Zara Larsson. In 2022, TikTok users started to post the lyrics of this song to make the “How Long Do Idiots Live” meme more interesting. So, when a TikTok user wants to show someone as an idiot, he or she sends the phrase “I’ll never forget you” as an idiot can live only up to 15 years.
Is it a Joke or an Insult?
An idiot is a person with intellectual disabilities. Therefore, using the term “idiot” to insult someone can be offensive. We have also seen people deliberately use this meme to insult others. However, many people believe that the purpose of the “How Long Do Idiots Live” meme is entirely to entertain people and spread laughter. No one should take it seriously.
“How Long Do X Live” TikTok Trends and Google Memes:
To continue the “How Long D X Live” trend, Gen-Z TikTok users post various other similar memes, including “How long do short people live”, “How long do tall people live?”, “How long do black people live”, “How long do white people live”, etc. In the same way, they ridiculous Google results for these questions to make fun of it, and the results are more or less the same “12 to 15 years”.
Besides the “How Long Do X Live” trend, many other trends went viral in recent years, such as “What is the biggest planet n Earth?” “What is the coldest place in the universe?”, “Am I a vampire?” and “Why were Graham crackers invented?” Sometimes you get funny Google results for these questions, sometimes people edit Google results to make funny memes.
Wrap Up
There is no scientific evidence to back the funny Google results. These memes are intended to entertain people. More importantly, not always Google shows the results, rather people edit the results. So, you should not believe these answers, instead, realize the intention behind the memes. However, Google has been taking measures to prevent the spreading of unusual results for the questions like “How Long Do Idiots Live?”
Subhajit Khara
Subhajit Kharahttps://www.embraceom.com/
Subhajit Khara is an Electronics & Communication engineer who has found his passion in the world of writing. With a background in technology and a knack for creativity, he has become a proficient content writer and blogger. His expertise lies in crafting engaging articles on a variety of topics, including tech, lifestyle, and home decoration.
Share this
Tags
Must-read
How Do Affordable RTA Cabinets Improve the Efficiency of Commercial Renovations for Renovation Companies? Expert Insights and Benefits
Affordable RTA cabinets can significantly improve the efficiency of commercial renovations. These cabinets are easy to assemble and cost-effective, providing a practical solution for...
Built-In or Freestanding – How to Choose the Bath For You
Choosing the right bath for your home is a decision that balances aesthetics, functionality, and personal preference. The primary types to consider are built-in...
Using Hearts In A Grown Up Way
Incorporating hearts into your aesthetic can be done in a sophisticated and mature manner, adding a touch of elegance and sentimentality without appearing overly...
Recent articles
More like this
|
__label__pos
| 0.599378 |
blob: e0433687675dcf0ce23041d4d3171337328b95a9 [file] [log] [blame]
// Copyright 2020 The Tint Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include "src/tint/sem/matrix_type.h"
#include "src/tint/program_builder.h"
#include "src/tint/sem/vector_type.h"
#include "src/tint/utils/hash.h"
TINT_INSTANTIATE_TYPEINFO(tint::sem::Matrix);
namespace tint {
namespace sem {
Matrix::Matrix(const Vector* column_type, uint32_t columns)
: subtype_(column_type->type()),
column_type_(column_type),
rows_(column_type->Width()),
columns_(columns) {
TINT_ASSERT(AST, rows_ > 1);
TINT_ASSERT(AST, rows_ < 5);
TINT_ASSERT(AST, columns_ > 1);
TINT_ASSERT(AST, columns_ < 5);
}
Matrix::Matrix(Matrix&&) = default;
Matrix::~Matrix() = default;
size_t Matrix::Hash() const {
return utils::Hash(TypeInfo::Of<Vector>().full_hashcode, rows_, columns_,
column_type_);
}
bool Matrix::Equals(const Type& other) const {
if (auto* v = other.As<Matrix>()) {
return v->rows_ == rows_ && v->columns_ == columns_ &&
v->column_type_ == column_type_;
}
return false;
}
std::string Matrix::FriendlyName(const SymbolTable& symbols) const {
std::ostringstream out;
out << "mat" << columns_ << "x" << rows_ << "<"
<< subtype_->FriendlyName(symbols) << ">";
return out.str();
}
bool Matrix::IsConstructible() const {
return true;
}
uint32_t Matrix::Size() const {
return column_type_->Align() * columns();
}
uint32_t Matrix::Align() const {
return column_type_->Align();
}
uint32_t Matrix::ColumnStride() const {
return column_type_->Align();
}
} // namespace sem
} // namespace tint
|
__label__pos
| 0.97564 |
Application Acceleration Technology – A Boon
Many corporations require combined voice, video and Internet access with a two-way Internet bandwidth of at least 100 Mbps. This is a forward-looking composite requirement that recognizes that a typical corporation with 250+ employees will be watching videos, talking on the telephone, and accessing the Internet all at the same time.
About 300 million people in the world are telecommuting to work today. Better, faster, and cheaper communication infrastructure would mean a phenomenal increase in productivity and a better quality of life.
Knowing the impact of Internet on mankind and despite hundreds of terabyte Internet bandwidth capacity across the world, what is stopping us from using bandwidth to its full extent? Why are we still talking of speed in terms of kilobits when hundreds of terabyte Internet capacities have already been laid and tested?
The fiber glut
There exists a vast international bandwidth capacity across all continents and countries connecting their various cities and towns and terminating at various places that are called Point of Presence (PoP). More than a billion Internet users exist throughout the world. The challenge consists of connecting these users to the nearest POP. The connectivity between various client sites and POPs, called the last mile connectivity, is the bottleneck.
Internet Service Providers (ISPs) built the long haul and backbone networks spending billions over the past five years. ISPs spent to this extent to increase the broadband capacity by 250 times in long haul; yet, the capacity in the metro area increased only 16 fold. Over this period, the last mile access has remained the same, with the result that data moves very slowly in the last mile. Upgrading to higher bandwidths is either not possible or the cost is extremely prohibitive. The growth of Internet seems to have reached a dead end, with possible adverse effects on the quality and quantity of the Internet bandwidth that is available for the growing needs of enterprises and consumers.Compounding this is the technical limitations of Transmission Control Protocol / Internet Protocol (TCP/IP).
TCP/IP limitations
The Internet works on a protocol called the TCP/IP. TCP/IP performs well over short-distance Local Area Network (LAN) environments but poorly over Wide Area Networks (WANs) because it was not designed for it.
TCP as a transport layer has several limitations that cause many applications to perform poorly, especially over distance. These include: window size limitations for transmission of data, slow start of data transmission, inefficient error recovery mechanisms, packet loss, and disruption of transmission of data. The net result of issues is poor bandwidth utilization. The typical bandwidth utilization for large data transfers over long-haul networks is usually less than 30 percent, and more often less than 10 percent. Even if a chance of upgrading the last miles even at very high costs exists, the effective increase would be only 10 percent of the upgraded bandwidth. Hence, upgrading networks is a very expensive proposition.
A new technology called the ‘Application Acceleration’ has emerged, which accelerates the Internet applications over WANs using the same Internet infrastructure, circumventing to some extent the problems caused due to lack of bandwidth.
Application accelerators, as the name suggests, are appliances that accelerate applications by reengineering the way data, video, and voice is sent/transmitted over networks. Application acceleration addresses non-bandwidth congestion problems caused by TCP and application-layer protocols, thereby, significantly reducing the size of the data being sent along with the number of packets it takes to complete a transaction, and performs other actions to speed up the entire process.
Application accelerators can also monitor the traffic and help with security. Some appliances mitigate performance issues by simply caching the data and/or compressing the data before transfer. Others have the ability to mitigate several TCP issues because of their superior architecture.
These appliances have the ability to mitigate latency issues, compress the data, and shield the application from network disruptions. Further, these new appliances are transparent to operations and provide the same transparency to the IP application as TCP/IP application accelerators have the following features using Layer 4-7 Switching.
Transport protocol conversion
Some data center appliances provide alternative transport delivery mechanisms between appliances. In doing so, they receive the optimized buffers from the local application and deliver them to the destination appliance for subsequent delivery to the remote application process. Alternative transport technologies are responsible for maintaining acknowledgements of data buffers and resending buffers when required.
They maintain a flow control mechanism on each connection in order to optimize the performance of each connection to match the available bandwidth and network capacity. Some appliances provide a complete transport mechanism for managing data delivery and use User Datagram Protocol (UDP) socket calls as an efficient, low overhead, data streaming protocol to read and write from the network.
Compression engine
A compression engine as part of the data center appliance compresses the aggregated packets that are in the highly efficient IP accelerator appliance buffers. This provides an even greater level of compression efficiency, since a large block of data is compressed at once rather than multiple small packets being compressed individually. Allowing compression to occur in the LAN-connected appliance frees up significant CPU cycles on the server where the application is resident.
Overcoming packet loss
The largest challenge in the TCP/IP performance improvements centers is the issue of packet loss. Packet loss is caused by network errors or changes better known as network exceptions. Most networks have some packet loss, usually in the 0.01 percent to 0.5 percent in optical WANs to 0.01 percent to 1 percent in copper-based Time Division Multiplexing (TDM) networks. Either way, the loss of up to one or more packets in every 100 packets causes the TCP transport to retransmit packets, slows down the transmission of packets from a given source, and re-enters slow-start mode each time a packet is lost. This error recovery process causes the effective throughput of a WAN to drop to as low as 10 percent of whatever the available bandwidth is between two sites.
IP application accelerators optimize blocks of data traversing the WAN by maintaining acknowledgements of the data buffers and only sending the buffers that did not make it, and not the whole frame. This allows for the use of a better transport protocol that will not retract data or move into a slow start mode. Using a more efficient transport protocol has lower overhead and streams the data on reads and writes cycles from source to destination. This is completely transparent to the process running a given server application.
Caching
Web documents retrieved may be stored (cached) for a time so that they can be conveniently accessed if further requests are made for them. There is no need for the entire data to move cross the network and only updating requests are sent across, thereby optimizing network bandwidth.
Server load Balancing
Server load balancers distribute processing and communications activity evenly across a computer network so that no single device is overwhelmed. Load balancing is especially important for networks where it is difficult to predict the number of requests that will be issued to a server. Busy Web sites/Web sites with a heavy traffic typically employ two or more Web servers in a load-balancing scheme.
SSL acceleration
Secure sockets layer (SSL) is a popular method for encrypting data that is transferred over the Internet. SSL acceleration is a method of offloading the processor-intensive public key encryption algorithms involved in SSL transactions to a hardware accelerator. Typically, this is a separate card in an appliance that contains a co-processor able to handle most of the SSL processing.
Despite the fact that it uses faster symmetric encryption for confidentiality, SSL still causes a performance slowdown. That is because there is more to SSL than the data encryption. The “handshake” process, whereby the server (and sometimes the client) is authenticated, uses digital certificates based on asymmetric or public key encryption technology. Public key encryption is very secure, but also very processor-intensive and thus has a significant
negative impact on performance. The method used to address the SSL performance problem is the hardware accelerator. By using an intelligent card that plugs into a PCI slot or SCSI port to do the SSL processing, it relieves the load on the Web server’s main processor.
Connection multiplexing
Connection multiplexing works by taking advantage of a feature in HTTP/1.1 that allows for multiple HTTP requests to be made over the same TCP connection. So instead of passing each HTTP connection from the client to the server in a one-to-one manner, the appliance combines many separate HTTP requests from clients into relatively few HTTP connections to the server. This keeps the connections to the server open across multiple requests, thus eliminating the high turnover that is typically encountered in high volume Web sites. The ultimate result is that there is higher performance out of the same servers without any changes or improvements to the server infrastructure.
Clustering
A cluster is a group of application servers that transparently run applications as if it were a single entity. Clusters can comprise redundant and fail over-capable machines: A typical cluster in a network integrates Layer 4-7 Load Balancers, Gateway Routers, which exist at the end of a network on each side, and various switches in a network, which integrates the application and Web Servers with the whole Network. Firewalls are used in filtering port level access to all network resources and data storage devices (which can use any media such as Tape drives, Magneto- Optical drives or Simple hard drives). A cluster manages the writing of data on main storage devices as well as the redundant ones and manages switchover to redundant storage media in case of a failure of primary data storage devices.
Network security (Firewalls)
Network security protects the networks and their services from unauthorized modification, destruction, or disclosure, and provides assurance that the network performs its critical functions correctly and that there are no harmful side effects. It also includes providing for data integrity. Gateway that limits access between networks in accordance with local security policy is called Firewalls and can be implemented in Layer 4-7 Switching.
Firewalls are used to prevent unauthorized Internet users from accessing private networks. All messages entering or leaving the intranet pass through the firewall, which examines each message and blocks those that do not meet the specified security criteria.A firewall is usually considered a first line of defense in protecting private information.
Bandwidth management, QoS, monitoring and reporting
Bandwidth management appliances allocate bandwidth to mission-critical applications, slow down non-critical applications, and stop bandwidth abuse in order to efficiently deliver networked applications to the branch office. The primary goal of Quality of Service (QoS) is to provide priority including dedicated bandwidth, controlled jitter, and atency (required by some real-time and interactive traffic) to applications traveling on the network.
End-to-end performance monitoring and reporting provides the WAN visibility required to analyze the traffic; Layer 7 QoS allocates bandwidth according to rules and policies. Traffic is automatically categorized into application classes.
Easy to understand shaping policies such as “real-time” or “block” govern the flow of traffic. Packet fragmentation assures that large data packets do not violate VoIP/video latency budgets, while packet aggregation ensures higher WAN capacity and stabilizes jitter. This guarantees that delay-sensitive traffic such as VoIP can be allocated a minimum amount of bandwidth to ensure optimal voice quality even when WAN links are congested or oversubscribed.
The net result of these features is that very high data transfer speeds, some times as much as 10X, are achieved. This technology has come as a boon to the Internet-starved industry achievement of higher bandwidth speeds and means that organizations can now look forward to explosive growth in their Internet business.
The demand for Internet bandwidth is bound to increase by the day. The application acceleration technology is expected to give the much-needed respite to ISPs and the Government to better plan and implement the last miles on the best possible media and resolve the last mile bottlenecks forever.
Next Post
Overusing Your Health Insurance
When reviewing health plans and evaluating cost, keep in mind health insurance wasn’t designed to cover every penny related to health care. Everything under the sun on an open credit card is nice, but not when you are paying the bill. But you are. The purpose of insurance is to […]
|
__label__pos
| 0.674155 |
[email protected] list mirror (unofficial, one of many)
help / color / mirror / code / Atom feed
blob 470107248eb161b9314ceb0ab93f21f072cf86cd 7048 bytes (raw)
name: t/t0021/rot13-filter.pl # note: path name is non-authoritative(*)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
#
# Example implementation for the Git filter protocol version 2
# See Documentation/gitattributes.txt, section "Filter Protocol"
#
# The first argument defines a debug log file that the script write to.
# All remaining arguments define a list of supported protocol
# capabilities ("clean", "smudge", etc).
#
# This implementation supports special test cases:
# (1) If data with the pathname "clean-write-fail.r" is processed with
# a "clean" operation then the write operation will die.
# (2) If data with the pathname "smudge-write-fail.r" is processed with
# a "smudge" operation then the write operation will die.
# (3) If data with the pathname "error.r" is processed with any
# operation then the filter signals that it cannot or does not want
# to process the file.
# (4) If data with the pathname "abort.r" is processed with any
# operation then the filter signals that it cannot or does not want
# to process the file and any file after that is processed with the
# same command.
# (5) If data with a pathname that is a key in the DELAY hash is
# requested (e.g. "test-delay10.a") then the filter responds with
# a "delay" status and sets the "requested" field in the DELAY hash.
# The filter will signal the availability of this object after
# "count" (field in DELAY hash) "list_available_blobs" commands.
# (6) If data with the pathname "missing-delay.a" is processed that the
# filter will drop the path from the "list_available_blobs" response.
# (7) If data with the pathname "invalid-delay.a" is processed that the
# filter will add the path "unfiltered" which was not delayed before
# to the "list_available_blobs" response.
#
use 5.008;
sub gitperllib {
# Git assumes that all path lists are Unix-y colon-separated ones. But
# when the Git for Windows executes the test suite, its MSYS2 Bash
# calls git.exe, and colon-separated path lists are converted into
# Windows-y semicolon-separated lists of *Windows* paths (which
# naturally contain a colon after the drive letter, so splitting by
# colons simply does not cut it).
#
# Detect semicolon-separated path list and handle them appropriately.
if ($ENV{GITPERLLIB} =~ /;/) {
return split(/;/, $ENV{GITPERLLIB});
}
return split(/:/, $ENV{GITPERLLIB});
}
use lib (gitperllib());
use strict;
use warnings;
use IO::File;
use Git::Packet;
my $MAX_PACKET_CONTENT_SIZE = 65516;
my $log_file = shift @ARGV;
my @capabilities = @ARGV;
open my $debug, ">>", $log_file or die "cannot open log file: $!";
my %DELAY = (
'test-delay10.a' => { "requested" => 0, "count" => 1 },
'test-delay11.a' => { "requested" => 0, "count" => 1 },
'test-delay20.a' => { "requested" => 0, "count" => 2 },
'test-delay10.b' => { "requested" => 0, "count" => 1 },
'missing-delay.a' => { "requested" => 0, "count" => 1 },
'invalid-delay.a' => { "requested" => 0, "count" => 1 },
);
sub rot13 {
my $str = shift;
$str =~ y/A-Za-z/N-ZA-Mn-za-m/;
return $str;
}
print $debug "START\n";
$debug->flush();
packet_initialize("git-filter", 2);
my %remote_caps = packet_read_and_check_capabilities("clean", "smudge", "delay");
packet_check_and_write_capabilities(\%remote_caps, @capabilities);
print $debug "init handshake complete\n";
$debug->flush();
while (1) {
my ( $res, $command ) = packet_key_val_read("command");
if ( $res == -1 ) {
print $debug "STOP\n";
exit();
}
print $debug "IN: $command";
$debug->flush();
if ( $command eq "list_available_blobs" ) {
# Flush
packet_compare_lists([1, ""], packet_bin_read()) ||
die "bad list_available_blobs end";
foreach my $pathname ( sort keys %DELAY ) {
if ( $DELAY{$pathname}{"requested"} >= 1 ) {
$DELAY{$pathname}{"count"} = $DELAY{$pathname}{"count"} - 1;
if ( $pathname eq "invalid-delay.a" ) {
# Send Git a pathname that was not delayed earlier
packet_txt_write("pathname=unfiltered");
}
if ( $pathname eq "missing-delay.a" ) {
# Do not signal Git that this file is available
} elsif ( $DELAY{$pathname}{"count"} == 0 ) {
print $debug " $pathname";
packet_txt_write("pathname=$pathname");
}
}
}
packet_flush();
print $debug " [OK]\n";
$debug->flush();
packet_txt_write("status=success");
packet_flush();
} else {
my ( $res, $pathname ) = packet_key_val_read("pathname");
if ( $res == -1 ) {
die "unexpected EOF while expecting pathname";
}
print $debug " $pathname";
$debug->flush();
# Read until flush
my ( $done, $buffer ) = packet_txt_read();
while ( $buffer ne '' ) {
if ( $buffer eq "can-delay=1" ) {
if ( exists $DELAY{$pathname} and $DELAY{$pathname}{"requested"} == 0 ) {
$DELAY{$pathname}{"requested"} = 1;
}
} else {
die "Unknown message '$buffer'";
}
( $done, $buffer ) = packet_txt_read();
}
if ( $done == -1 ) {
die "unexpected EOF after pathname '$pathname'";
}
my $input = "";
{
binmode(STDIN);
my $buffer;
my $done = 0;
while ( !$done ) {
( $done, $buffer ) = packet_bin_read();
$input .= $buffer;
}
if ( $done == -1 ) {
die "unexpected EOF while reading input for '$pathname'";
}
print $debug " " . length($input) . " [OK] -- ";
$debug->flush();
}
my $output;
if ( exists $DELAY{$pathname} and exists $DELAY{$pathname}{"output"} ) {
$output = $DELAY{$pathname}{"output"}
} elsif ( $pathname eq "error.r" or $pathname eq "abort.r" ) {
$output = "";
} elsif ( $command eq "clean" and grep( /^clean$/, @capabilities ) ) {
$output = rot13($input);
} elsif ( $command eq "smudge" and grep( /^smudge$/, @capabilities ) ) {
$output = rot13($input);
} else {
die "bad command '$command'";
}
if ( $pathname eq "error.r" ) {
print $debug "[ERROR]\n";
$debug->flush();
packet_txt_write("status=error");
packet_flush();
} elsif ( $pathname eq "abort.r" ) {
print $debug "[ABORT]\n";
$debug->flush();
packet_txt_write("status=abort");
packet_flush();
} elsif ( $command eq "smudge" and
exists $DELAY{$pathname} and
$DELAY{$pathname}{"requested"} == 1 ) {
print $debug "[DELAYED]\n";
$debug->flush();
packet_txt_write("status=delayed");
packet_flush();
$DELAY{$pathname}{"requested"} = 2;
$DELAY{$pathname}{"output"} = $output;
} else {
packet_txt_write("status=success");
packet_flush();
if ( $pathname eq "${command}-write-fail.r" ) {
print $debug "[WRITE FAIL]\n";
$debug->flush();
die "${command} write error";
}
print $debug "OUT: " . length($output) . " ";
$debug->flush();
while ( length($output) > 0 ) {
my $packet = substr( $output, 0, $MAX_PACKET_CONTENT_SIZE );
packet_bin_write($packet);
# dots represent the number of packets
print $debug ".";
if ( length($output) > $MAX_PACKET_CONTENT_SIZE ) {
$output = substr( $output, $MAX_PACKET_CONTENT_SIZE );
} else {
$output = "";
}
}
packet_flush();
print $debug " [OK]\n";
$debug->flush();
packet_flush();
}
}
}
debug log:
solving 470107248eb ...
found 470107248eb in https://80x24.org/mirrors/git.git
(*) Git path names are given by the tree(s) the blob belongs to.
Blobs themselves have no identifier aside from the hash of its contents.^
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).
|
__label__pos
| 0.974919 |
Manual Testing Interview Questions
Questions Answers Views Company eMail
can any one tell me wat is dependent and independent scripting?
Cap Gemini,
894
Requirement is given : 1) The Login screen should require with 2 fields "Login" & "Password" 2) After successful login Success Message will display. 3) For Invalid login Error Message will display. 4) "Login" & "Password" both fields are case insensitive. 5) The Application should be Dialog application. What are the test cases for above requirements?
4 8084
Hello, Currently we are doing manual testing for PHP& .NET Projects. We are planning to automate it.Kindly suggest which automation testing tool is appropriate for it. Thanks
3 2642
What is Dialog Application? Tell me in details about it? Thankd in Advance
877
As there are different builds for every version & any build can release to the client.I m using Excell sheet for Test Case writting. Then Am I write Version No/build No.newly added feature test cases. Because when that build again release for testing I can understand that this build have that feature.
1 1545
I m writting the test cases in Excel sheet. After wrting test cases for version 2.0.0 If there is new feature added in build 2.0.1, I will write test cases for newly added feature. Then 3.0 version release for testing with new feature. I will write test cases for newly added feature 3.0 But if in between 2.0.2 build release for testing with same feature of 3.0.Then should I have to write test cases for same feature again? If not --> when 2.0.2build again release for testing after 2months then How should I came to know that I have to run these test cases on 2.0.2build?
2 2810
What is Internal Links, External Links, orphan Pages, Broken Links
2 9450
Who will assign severity and priority to the bug?
10 16273
what is version 1
11 4959
in your organization in what way(phases) s/w is developed and in what way testing will be conducted?
4 2800
If there is dropdown field say Select Category. & Default category is Indian. What are the test cases for this field?
3 2645
If any bug is found in exploratory testing, then may I consider it as a test case?
2 2440
I would like to know about the steps to follow for testing a .NET web application. Please provide detailed steps with more general scenarios.
3 2805
Hi, Glamrous Should I write the test case for dropdown field For Above: -ve test case Test Case Name Expected Esult Without selecting Category - Default category should get select Is this a valid test case?
2 3389
What is Trivial Bug?
2 18387
Post New Manual Testing Questions
Un-Answered Questions { Manual Testing }
aplitue questions will be based on wich type ?
1385
Tell me a critical defect in which your Client,PM,PL appreciate on you
785
Hi friends Does anyone have screen shot of POWERMHS and please can anyone post anything which will be helpful to understand POWERMHS. thanks.
1457
1.How to maintain the Bug status Report? 2.What is project based Company and product based company?
5302
What are the cases why parameterization is necessary when load testing the Web server and the database server?
948
Why should you care about objects and object-oriented testing?
1210
. Is any graph is used for code coverage analysis?
1355
Please Provide me the link to download Testing Category questions and answers If some body has downloaded it pleae send it to me Pavan : Email [email protected] Quetion2 : Can any body Explain me about Testing thumb rules
983
integration test cases for mouse and keyboard
2402
How to do integration testing on duster......
535
1)can u tell me, what is the roles and responsibles for database tester in DB testing from requirement stage to UAT stage....2) what are the i/p documents he wants and who wil give the i/p docs. to DB tester.and tell me what exactly db test case means what?
1258
How would u test and automate an Antivirus application ?
882
Hi, i am looking job in perfomance testing using Loadrunner can any body help me a project in any domine plz(Usah) [email protected]
903
Build with fixes has been deployed on QA environment if asked by your manager to reproduce how can you reproduce the issues? (by using the previous build) Can you access the previous build? If so ,what are the tools or how can you access?
531
Our software designers use UML for modeling applications. Based on their use cases, we would like to plan a test strategy. Do you agree with this approach or would this mean more effort for the testers.
899
|
__label__pos
| 0.999858 |
Definitions for Differentialˌdɪf əˈrɛn ʃəl
This page provides all possible meanings and translations of the word Differential
Random House Webster's College Dictionary
dif•fer•en•tialˌdɪf əˈrɛn ʃəl(adj.)
1. of or pertaining to difference or diversity.
2. constituting a difference; distinguishing; distinctive.
3. exhibiting or depending upon a difference or distinction.
4. pertaining to or involving the difference of two or more motions, forces, etc.
Category: Physics
5. pertaining to or involving a mathematical derivative or derivatives.
Category: Math
6. (n.)a difference or the amount of difference, as in rate, cost, degree, or quality, between things that are comparable.
7. Category: Machinery
Ref: differential gear.
8. Math. a function of two variables that is obtained from a given function, y = f(x), and that expresses the approximate increment in the given function as the derivative of the function times the increment in the independent variable, written as dy = f~(x) any generalization of this function to higher dimensions.
dx.
Category: Math
9. Physics. the quantitative difference between two or more forces, motions, etc.:
a pressure differential.
Category: Physics
Origin of differential:
1640–50; < ML
dif`fer•en′tial•ly(adv.)
Princeton's WordNet
1. derived function, derivative, differential coefficient, differential, first derivative(noun)
the result of mathematical differentiation; the instantaneous change of one quantity relative to another; df(x)/dx
2. differential(noun)
a quality that differentiates between similar things
3. differential gear, differential(adj)
a bevel gear that permits rotation of two shafts at different speeds; used on the rear axle of automobiles to allow wheels to rotate at different speeds on curves
4. differential(adj)
relating to or showing a difference
"differential treatment"
5. differential(adj)
involving or containing one or more derivatives
"differential equation"
Wiktionary
1. differential(Noun)
the differential gear in an automobile etc
2. differential(Noun)
a qualitative or quantitative difference between similar or comparable things
3. differential(Noun)
an infinitesimal change in a variable, or the result of differentiation
4. differential(Adjective)
of, or relating to a difference
5. differential(Adjective)
dependent on, or making a difference; distinctive
6. differential(Adjective)
having differences in speed or direction of motion
7. differential(Adjective)
of, or relating to differentiation, or the differential calculus
Webster Dictionary
1. Differential(adj)
relating to or indicating a difference; creating a difference; discriminating; special; as, differential characteristics; differential duties; a differential rate
2. Differential(adj)
of or pertaining to a differential, or to differentials
3. Differential(adj)
relating to differences of motion or leverage; producing effects by such differences; said of mechanism
4. Differential(noun)
an increment, usually an indefinitely small one, which is given to a variable quantity
5. Differential(noun)
a small difference in rates which competing railroad lines, in establishing a common tariff, allow one of their number to make, in order to get a fair share of the business. The lower rate is called a differential rate. Differentials are also sometimes granted to cities
6. Differential(noun)
one of two coils of conducting wire so related to one another or to a magnet or armature common to both, that one coil produces polar action contrary to that of the other
7. Differential(noun)
a form of conductor used for dividing and distributing the current to a series of electric lamps so as to maintain equal action in all
Freebase
1. Differential
A differential is a device, usually, but not necessarily, employing gears, which is connected to the outside world by three shafts, chains, or similar, through which it transmits torque and rotation. The gears or other components make the three shafts rotate in such a way that, where, and are the angular velocities of the three shafts, and and are constants. Often, but not always, and are equal, so is proportional to the sum of and . Except in some special-purpose differentials, there are no other limitations on the rotational speeds of the shafts, apart from the usual mechanical/engineering limits. Any of the shafts can be used to input rotation, and the other to output it. See animation of a simple differential in which and are equal. The shaft rotating at speed is at the bottom-right of the image. In automobiles and other wheeled vehicles, a differential is the usual way to allow the driving roadwheels to rotate at different speeds. This is necessary when the vehicle turns, making the wheel that is travelling around the outside of the turning curve roll farther and faster than the other. The engine is connected to the shaft rotating at angular velocity . The driving wheels are connected to the other two shafts, and and are equal. If the engine is running at a constant speed, the rotational speed of each driving wheel can vary, but the sum of the two wheels' speeds can not change. An increase in the speed of one wheel must be balanced by an equal decrease in the speed of the other.
Translation
Find a translation for the Differential definition in other languages:
Select another language:
Discuss these Differential definitions with the community:
Citation
Use the citation below to add this definition to your bibliography:
Style:MLAChicagoAPA
"Differential." Definitions.net. STANDS4 LLC, 2014. Web. 8 Mar. 2014. <http://www.definitions.net/definition/Differential>.
Are we missing a good definition for Differential?
The Web's Largest Resource for
Definitions & Translations
A Member Of The STANDS4 Network
Nearby & related entries:
Alternative searches for Differential:
|
__label__pos
| 0.97149 |
Equations of slope?
• Thread starter alliereid
• Start date
• Tags
Slope
• #1
18
0
What is the defining equation of the concept of slope?
I thought it could be rise / run = m or Y2-Y1 / X2-X1 = m but then the next question asks to give the two common forms of the mathematical equation for slope involving X and Y? So would that not be those two equations?
Answers and Replies
• #2
I would say the the equation they are looking for would be:
Slope/gradient (m) = y2-y1 / x2-x1
Not sure what the other one would be...Unless you're doing calculus in which case it could be the derivative (slope) at a particular point.
eg. f'(x) = 2x^2 + 1 at the point where x=2
Therefore you have both your 'x' value and 'y' value because technically f(x) = y
Hope that helped...
• #3
sin or tan of the angle of slope are both commonly used
• #4
Sometimes the Greek letter Δ is used to signify the change in a quantity or variable. That might be what they are looking for.
Suggested for: Equations of slope?
Back
Top
|
__label__pos
| 0.999984 |
Multi-user setup error selecting the color pallete
Hi
I mounted the Multi-User setup following this guide https://kitware.github.io/paraviewweb/docs/multi_user_setup.html
In the client-side, first thing i do is open the file
_this.pvwClient.ProxyManager.open(_this.pathFileToOpen)
.then(function (response) {
if (response.success) {
_this.viewId = response.id; // save view id
_this.setState({
valid: true
});
} else {
//TODO: show error message
}
})
And then, I have in another button to change in a hardcoded way the pallet color with
this.pvwClient.ColorManager.listColorMapNames()
.then((response) => {
this.pvwClient.ColorManager.selectColorMap(this.viewId, response[0])
.then((response) => {
var foo= response;
})
.catch((response) => {
debugger;
var bar = response;
});
})
.catch(() => {
debugger;
var pepe = response;
});
But it always goes for the catch of the selectColorMap, it says the following
RunTime error : ‘vtkPVServerManagerCorePython.vtkSMSourceProxy’ object has no attribute ‘LookupTable’
Then I checked the code on the server side and found this
I got that from the documentation
https://kitware.github.io/paraview-docs/latest/python/_modules/paraview/web/protocols.html#ParaViewWebColorManager.selectColorMap
In ParaView is in the following path
lib/python2.7/site-package/paraview/web/protocols.py
I tried different things to get some result
1. Modify the SelectColorMap API
repProxy = self.mapIdToProxy(representation)
rep = simple.GetRepresentation(repProxy)
lutProxy = rep.GetProperty(‘LookupTable’).GetData()
But the flows goes through
“return { ‘result’: ‘Representation proxy ’ + representation + ’ is missing lookup table’ }”
1. Modify the alwaysIncludedProperties
in the init of ProxyManager, the alwaysIncludePropertie by default is self.alwaysIncludeProperties = [ ‘CubeAxesVisibility’]
I modified it to put the LookUpTable to this self.alwaysIncludeProperties = [ ‘CubeAxesVisibility’,‘LookupTable’ ], but nothing happend, im getting the same error.
2. View the properties of the rep through the log
First, I set the debug mode on true, and then I put this lines
repProxy = self.mapIdToProxy(representation)
rep = simple.GetRepresentation(repProxy)
lutProxy = rep.GetProperty(‘LookupTable’).GetData()
for attr, value in rep.__ dict__.iteritems():
print "Attribute: " + str(attr or “”)
print "Value: " + str(value or “”)
and I get this long log file ceb332c0-c139-11e8-90a0-080027000935.txt (273.1 KB)
It has a property ““LookupTable””, but when I am getting it, I got the error
“return { ‘result’: ‘Representation proxy ’ + representation + ’ is missing lookup table’ }”
So my question is,
How do I set the LookupTable for the representation?
Which method I do have to use previously?
I don’t know what else can I do.
Im trying to set the color hardcoded and then do the same dynamically.
Thanks!
I tried to use the getCurrentScalarRange(this.viewId) but it catch’s the following error
‘NoneType’ object has no attribute ‘RGBPoints’", under the blue line
getCurrentScaleRange
You need to provide the representation not the source.
The idea is when you load some data or apply a filter, you get a data source.
Then if you want to see that source in a view, you need to create a representation. Which is usually automatic here. But they are two independent proxies.
The missing part on your end is to find the proxy id of the representation that correspond to your source. You can achieve that by requesting the list of proxies with the following function call:
@exportRpc("pv.proxy.manager.list")
def list(self, viewId=None):
[...]
This will provide you a list of all your sources along with the corresponding representation.
HTH,
Seb
The proxy id that needs to be provided to the getCurrentScalarRange is the source, not the view.
Well, I tried to do the list()
list()
To get the rep for my id, and then use it to use selectColorPallette but when I do that, I get the error
Representation 565 is missing lookup table
Also tried to use getSurfaceOpacity, it uses the same logic to get the lookup table, but it throws the following runtime error ‘NoneType’ object has no attribute 'EnableOpacityMapping’
Maybe I’m doing another wrong thing, I have all the code public in my repository
Thanks for answering, I did not expect to get an answer a Saturday night haha
I think the next issue is that you need to choose which array you want to color by first. Otherwise no LookupTable get assigned to the representation.
Try to call that first:
@exportRpc("pv.color.manager.color.by")
def colorBy(self, representation, colorMode, arrayLocation='POINTS', arrayName='', vectorMode='Magnitude', vectorComponent=0, rescale=False):
[...]
BTW, you should rename your _this.viewId after the open call as it is truly the sourceId, not the viewId.
Hey Sebastien!
Thanks for the recommendation to rename to sourceId, I think I’m missing out a lot of concepts and doing a lot of try-error until success haha
I used the ColorBy method this way and saved all the palettes to iterate through them later
colorBy%20and%20listColorMapNames
And now every time I push the button I change the palette iterating thrown the array
button%20action
The response says {“result” : “success”}
but I don’t see any change
Do i have to do anything else?
The whole idea of this post is to do something similar to how Visualizer handle the colors
palleteVisualizer
I believe the colorMode value ‘’ is not valid.
You should look for the ParaView guide (Free Online PDF) and read the Python section. This should give you the background that you need between Source/Representation/View and how they work together.
Then you can use Visualizer to see what kind of calls are made via the Network inspector in your browser as you can see all the frames on the WebSocket connection. That way you will see the calls that are made and with which parameters to achieve a specific action.
|
__label__pos
| 0.740788 |
A particular strain of bacteria doubles in population every 10 minutes. Assuming you start with a single bacterium in a petri dish, how many bacteria will there be in 2.5 hours?
1 Answer
Aug 3, 2016
#32,768#
Explanation:
The trick here is to realize that you can express the increase in population as a power of #2#.
You know that every #10# minutes, the number of bacteria will double. If you take #x_0# to be the initial number of bacteria, you can say that
• #x_0 * 2 -># after #10# minutes
• #(x_0 * 2) * 2 = x_0 * 2^color(red)(2) -># after #color(red)(2) * 10# mintues
• #(x_0 * 2^2) * 2 = x_0 * 2^color(red)(3) -># after #color(red)(3) * 10# minutes
• #(x_0 * 2^3) * 2= x_0 * 2^color(red)(4) -># after #color(red)(4) * 10# minutes
#vdots#
and so on. As you can see, you can say that the number of bacteria present after #t# minutes, #x#, will be
#color(purple)(|bar(ul(color(white)(a/a)color(black)(x = x_0 * 2^n)color(white)(a/a)|)))#
Here
#n# - the number of #10#-minute intervals that pass in #t# minutes
In your case, you know that #t# is equal to
#2.5 color(red)(cancel(color(black)("h"))) * "60 min"/(1color(red)(cancel(color(black)("h")))) = "150 minutes"#
So, how many #10#-minute intervals do you have here?
#n = (150 color(red)(cancel(color(black)("min"))))/(10color(red)(cancel(color(black)("min")))) = 15#
Since you start with a single bacterium in a Petri dish, you have #x_0 = 1# and
#color(green)(|bar(ul(color(white)(a/a)color(black)(x = "1 bacterium" * 2^15 = "32,768 bacteria")color(white)(a/a)|)))#
|
__label__pos
| 1 |
Foenix.com
How many days since July 29, 1917?
Question about the past: How many days since July 29, 1917?
Here we will calculate how many days since July 29, 1917. We do so by counting EVERY day between today which is and July 29, 1917.
In other words, to solve the problem and answer the question, we use the following equation: Today's Date - Past Date = Days since past date
Using the formula above with today's date and the past date of July 29, 1917, we get the following: - July 29, 1917 =
Thus, the answer to the question, "How many days since July 29, 1917?" is as follows:
Days Since
How many days since
Are you looking for how many days since a different date? No problem. To find how many days since a different date, please go here.
July 1917 Calendar
Go here to see the calendar for July 1917.
Copyright | Privacy Policy | Disclaimer | Days since 1917 | Contact
|
__label__pos
| 0.696807 |
Specification: Ballerina UDP Library
Owners: @Maninda @MohamedSabthar @shafreenAnfar
Reviewers: @shafreenAnfar @Maninda
Created: 2020/11/10
Updated: 2022/02/18
Edition: Swan Lake
Introduction
This is the specification for the UDP standard library of Ballerina language, which provides UDP client-server functionalities.
The UDP library specification has evolved and may continue to evolve in the future. The released versions of the specification can be found under the relevant GitHub tag.
If you have any feedback or suggestions about the library, start a discussion via a GitHub issue or in the Slack channel. Based on the outcome of the discussion, the specification and implementation can be updated. Community feedback is always welcome. Any accepted proposal, which affects the specification is stored under /docs/proposals. Proposals under discussion can be found with the label type/proposal in GitHub.
The conforming implementation of the specification is released and included in the distribution. Any deviation from the specification is considered a bug.
Contents
1. Overview
2. User Datagram Protocol (UDP)
3. Client
4. Service
5. Samples
1. Overview
This specification elaborates on Basic UDP clients and services/listeners.
2. User Datagram Protocol
UDP is the transport layer protocol used for unreliable connectionless data communication across a network.
Ballerina UDP library has the capability of sending and receiving data via UDP protocol using both clients and services.
3. Client
Introduce two different clients, one for connectionless scenarios and another for connection oriented scenarios.
3.1 Datagram
A self-contained, independent entity of data carrying sufficient information to be routed from the source to the destination nodes without reliance on earlier exchanges between the nodes and the transporting network.
3.2 Connectionless Client
Follows the principles of pure UDP protocol with connectionless data.
3.2.1 init function
Binds the client to the host address that is provided in config. Otherwise bind the client to localhost with an ephemeral port.
3.2.2 sendDatagram function
A blocking method where each execution of this method will result in sending a datagram to the remote host or in error, nothing in between. If the byte[] size is too large than what the native networking software can support, the method may or may not return an error. This is entirely dependent on the host machine and the OS. Following is the list of categorization of Datagram data sizes,
• IPv4 theoretical size limit 65507 bytes
• IPv6 theoretical size limit 65536 bytes
• Practical safe size limit which many protocols use 8192 bytes
• Max practical safe size limit 512 bytes
3.2.3 receiveDatagram function
Listened datagrams are retrieved one-by-one. If an error happens during the receiving, an error is returned.
3.2.4 close function
Clears the external-party-related information from the client.
3.3 Connection Oriented Client
Is configured so that it only receives datagrams from an external party, and sends datagrams to an external party, using the given remote address. Once connected, datagrams may not be received from or sent to any other address. The client remains connected until it is explicitly disconnected or until it is closed.
3.3.1 writeBytes function
Writes everything in the data to the remote server. If the data’s byte[] is too large it writes multiple Datagrams until the size of the byte[] is zero.
3.3.2 readBytes function
Reads data as byte[]s received from the external party. Returns an error if any interruption happens during the receive operation.
3.3.3 close function
Clears the external-party-related information from the client.
4. Service
A service can listen to a listener to read data from the UDP socket. Following types are defined to implement the UDP listener-based read/write operations.
4.1 Listener
4.1.1 Configuration
Configured using the record, ListenerConfiguration with the connection details required. In absense of remotePort, the listener does not listen to a remote port but to the local port.
4.1.2 init function
Initialize the listener with the given details.
4.2 Service
4.3 Caller
Similar in behavior to a client.
4.3.1 sendDatagram function
sendDatagram function send pre-defined datagrams one-by-one.
4.3.2 sendBytes function
Similar to the sendDatagram function but can be given data, longer than the allowed maximum size of a datagram, where data array is ieratively read and sent as a sequene of datagrams.
5 Samples
5.1 Client
5.1.1 Connectionless Client
5.1.2 Connection Oriented Client
5.2 Service
|
__label__pos
| 0.933004 |
See Google Earth coordinates in Excel - and convert them to UTM
I have data in Google Earth, and I want to visualize the coordinates in Excel. As you can see, it is a plot with 7 vertices and a house with four vertices.
Save Google Earth data.
To download this data, right click on "My places", and select "Save place as ..."
For being a file that has lines, points and properties that I have modified to the icons, the file will not be saved as a simple kml but as a Kmz.
What is a KMZ file?
A kmz is a set of compressed kml files. So, the easiest way to unzip it is as we would do with a .zip file or .rar.
As shown in the following graphic, it might be that we do not see the file extension. For this, we must do the following actions:
1 It activates the option to see the extension of the files, from the "Vista" tab of the file browser.
2 The extension from .kmz to .zip is changed. To do this, a soft click is made on the file, and the data that is after the point is modified. We accept the message that will appear, which indicates that we are changing the file extension and that it could become unusable.
3 The file is decompressed. Right mouse button, and "Extract in ..." is selected. In our case, the file is called "Aula Geofumadas".
As we can see, a folder was created, and right inside you can see the kml file called "doc.kml" and a folder called "files" that contains the associated data, in general images.
Open KML from Excel
What is a Kml file?
Kml is a format popularized by Google Earth, which was before the Keyhole company, hence the name (Keyhole Markup Language), therefore, it is a file in XML structure (eXtensible Markup Language). So, being an XML file must be able to be viewed from Excel:
1 We changed its extension from .kml to .xml.
2 We open the file from Excel. In my case, I'm using Excel 2015, I get a message if I want to see it as an XML table, as a read-only book or if I want to use the XML source panel. I select the first option.
3 We search the list of geographic coordinates.
4 We copy them to a new file.
And voila, now we have the file of the coordinates of Google Earth, in an Excel table. From row 29, in column X appear the names of the vertices, and the coordinates latitude / longitude in the column AH. I have hidden some columns, so you can see that in the 40 and 41 rows you can see the two polygons I drew, with their coordinate string.
So, with copying the X columns and the AH column, you have the objects and coordinates of your Google Earth points.
We hope that the above has helped you to understand how to save Google Earth data in a kmz file, as well as to understand how to pass a kmz file to kml, finally how to view Google Earth coordinates using Excel.
Interested in something else?
Convert data from Google Earth to UTM.
Now, if you want to convert those geographic coordinates that you have in the form of decimal degrees of latitude and longitude to a format of projected UTM coordinates, then you can use the template that exists for that.
What are UTM coordinates?
UTM (Universal Traverso Mercator) is a system that divides the globe in 60 zones of 6 degrees each, transformed in a mathematical way to resemble a grid projected on an ellipsoid; such as is explained in this article. Y in this video.
As you can see, there copies the coordinates shown above. As a result, you will have the X, Y coordinates and also the UTM Zone marked in the green column, which in that example appears in the 16 Zone.
Send data from Google Earth to AutoCAD.
In order to send the data to AutoCAD, you only have to activate the multi-point command. This is in the "Draw" tab, as shown in the drawing on the right.
Once you have activated the Multiple Points command, copy and paste the data from the Excel template, from the last column, to the AutoCAD command line.
With this, your coordinates have been drawn. To visualize them, Zoom / All can be done.
When you make the payment, you receive an email immediately, with the download link; if you do not see it, you should check the spam folder. Acquiring the template gives you the right to support by email, in case you have a problem with the template.
To 2 utm
Tagged with
Leave a comment
Your email address will not be published.
|
__label__pos
| 0.657821 |
pyrsmk/minisuite
Functional micro unit testing framework
5.0.1 2016-08-02 08:18 UTC
README
MiniSuite is a very concise and flexible unit testing tool which aims to have an intuitive and functional API. The reports are made to be simple to read.
A MiniSuite report
Installing
composer require pyrsmk/minisuite
Basics
MiniSuite does not need you to create a class for each test you want to run, you can write and organize your code as you want. Please note that all tests are runned when they're called.
$fruits = ['apple', 'peach', 'strawberry'];
$minisuite = new MiniSuite\Suite('My tests');
$minisuite->expects('I have 3 fruits in my basket') // define the expectation message
->that(count($fruits)) // define the value to verify
->equals(3); // 'equals' expectation
You can also chain your expectations :
$some_value = 72;
$minisuite->expects('Some message')
->that($some_value)
->isInteger()
->isGreaterThan(0)
->isLessThanOrEqual(100);
Specific tests on array elements are supported too :
$fruits = ['apples' => 12, 'peaches' => 7, 'strawberries' => 41];
$minisuite->expects('Verify strawberries stock')
->that($fruits, 'strawberries')
->isDefined()
->isInteger()
->isGreaterThan(0);
Closure support
MiniSuite support closures to execute more tasks when verifying values :
$minisuite->expects('Test')
->that(function($minisuite) {
return 72;
})
->equals(72);
Closures are automatically executed when they are passed to that(). If you need the closure value to not being run, like with throws and doesNotThrow expectations, you should protect it with :
$minisuite->expects('Test')
->that($minisuite->protect(function($minisuite) {
throws Exception();
}))
->throws();
The container
MiniSuite is based on the Chernozem container and we advise you to read its documentation to be able to use the advanced features, like services support for bigger testing projects.
You can access to the container by specifying a Closure in the that() method :
$minisuite['fruits'] = ['apples' => 12, 'peaches' => 7, 'strawberries' => 41];
$minisuite->expects('Verify strawberries stock')
->that(function($minisuite) {
return count($minisuite['fruits']['strawberries']) > 0;
})
->equals(true);
Hydrate your tests
For cleaner tests, you should hydrate them with your redundant code, like object creation. Each time a test is run, the hydrate function is run too, then you can have clean objects for each test.
$minisuite = new MiniSuite\Suite('My tests');
// Init configuration
$minisuite['conf'] = [
'path' => 'some/path/'
];
// Set hydrate function
$minisuite->hydrate(function($minisuite) {
$minisuite['logger'] = new SomeLogger($minisuite['conf']);
});
// Test the logger
$minisuite->expects('Verify logger path')
->that(function($minisuite) {
return $minisuite['logger']->getPath();
})
->equals('some/path/');
Available expectations
• isNull() : verify if the value is null
• isNotNull() : verify if the value is not null
• isEmpty() : verify if the value is empty (see the documentation for further informations)
• isNotEmpty() : verify if the value is not empty
• equals($value) : verify if the value is equal to the specified parameter
• doesNotEqual($value) : verify if the value is not equal to the specified parameter
• isLessThan($value) : verify if the value is less than the specified parameter
• isLessThanOrEqual($value) : verify if the value is less than or equal the specified parameter
• isGreaterThan($value) : verify if the value is greater than the specified parameter
• isGreaterThanOrEqual($value) : verify if the value is greater than or equal the specified parameter
• isBetween($min, $max) : verify if the value is between the specified values (not included)
• isNotBetween($min, $max) : verify if the value is not between the specified values (not included)
• isBoolean() : verify if the value is a boolean
• isNotBoolean() : verify if the value is not a boolean
• isInteger() : verify if the value is an integer
• isNotInteger() : verify if the value is not an integer
• isFloat() : verify if the value is a float
• isNotFloat() : verify if the value is not a float
• isString() : verify if the value is a string
• isNotString() : verify if the value is not a string
• isArray() : verify if the value is an array
• isNotArray() : verify if the value is not an array
• isObject() : verify if the value is an object
• isNotObject() : verify if the value is not an object
• isResource() : verify if the value is a resource
• isNotResource() : verify if the value is not a resource
• isCallable() : verify if the value is callable
• isNotCallable() : verify if the value is not callable
• isInstanceOf($class) : verify if the value is an instance of the specified class
• isNotInstanceOf($class) : verify if the value is not an instance of the specified class
• isTheSameAs($value) : verify if the value is the same as the specified value (it's like the === operator)
• isNotTheSameAs($value) : verify if the value is not the same as the specified value
• extends($class) : verify if the object extends the specified class
• doesNotExtend($class) : verify if the object does not extend the specified class
• throws($class) : if the class parameter is defined, it will verify that the protected closure throws an exception of the specified class, otherwise it will just verify that an exception has been throwed
• doesNotThrow($class) : if the class parameter is defined, it will verify that the protected closure does not throw an exception of the specified class, otherwise it will just verify that no exception has been throwed
Array elements have some more available expectations :
• isDefined() : verify if the element is defined
• isNotDefined() : verify if the element is not defined
License
MiniSuite is released under the MIT license.
|
__label__pos
| 0.685131 |
NAME PBKDF2::Tiny - Minimalist PBKDF2 (RFC 2898) with HMAC-SHA1 or HMAC-SHA2 VERSION version 0.002 SYNOPSIS use PBKDF2::Tiny qw/derive verify/; my $dk = derive( 'SHA-1', $pass, $salt, $iters ); if ( verify( $dk, 'SHA-1', $pass, $salt, $iters ) ) { # password is correct } DESCRIPTION This module provides an RFC 2898 compliant PBKDF2 implementation using HMAC-SHA1 or HMAC-SHA2 in under 100 lines of code. If you are using Perl 5.10 or later, it uses only core Perl modules. If you are on an earlier version of Perl, you need Digest::SHA or Digest::SHA::PurePerl. FUNCTIONS derive $dk = derive( $type, $password, $salt, $iterations, $dk_length ) The "derive" function outputs a binary string with the derived key. The first argument indicates the digest function to use. It must be one of: SHA-1, SHA-224, SHA-256, SHA-384, or SHA-512. If a password or salt are not provided, they default to the empty string, so don't do that! RFC 2898 recommends a random salt of at least 8 octets. If you need a cryptographically strong salt, consider Crypt::URandom. The number of iterations defaults to 1000 if not provided. If the derived key length is not provided, it defaults to the output size of the digest function. derive_hex Works just like "derive" but outputs a hex string. verify $bool = verify( $dk, $type, $password, $salt, $iterations, $dk_length ); The "verify" function checks that a given derived key (in binary form) matches the password and other parameters provided using a constant-time comparison function. The first parameter is the derived key to check. The remaining parameters are the same as for "derive". verify_hex Works just like "verify" but the derived key must be a hex string (without a leading "0x"). digest_fcn ($fcn, $block_size, $digest_length) = digest_fcn('SHA-1'); $digest = $fcn->($data); This function is used internally by PBKDF2::Tiny, but made available in case it's useful to someone. Given one of the valid digest types, it returns a function reference that digests a string of data. It also returns block size and digest length for that digest type. hmac $key = $digest_fcn->($key) if length($key) > $block_sizes; $hmac = hmac( $data, $key, $digest_fcn, $block_size ); This function is used internally by PBKDF2::Tiny, but made available in case it's useful to someone. The first two arguments are the data and key inputs to the HMAC function. Note: if the key is longer than the digest block size, it must be preprocessed using the digesting function. The third and fourth arguments must be a digesting code reference (from "digest_fcn") and block size. SEE ALSO * Crypt::PBKDF2 * Digest::PBDKF2 SUPPORT Bugs / Feature Requests Please report any bugs or feature requests through the issue tracker at . You will be notified automatically of any progress on your issue. Source Code This is open source software. The code repository is available for public review and contribution under the terms of the license. git clone https://github.com/dagolden/PBKDF2-Tiny.git AUTHOR David Golden COPYRIGHT AND LICENSE This software is Copyright (c) 2014 by David Golden. This is free software, licensed under: The Apache License, Version 2.0, January 2004
|
__label__pos
| 0.900312 |
Anti-spam plugin
Discussion in 'Suggestions' started by MorganDoezn'tPlayMc, May 2, 2014.
1. MorganDoezn'tPlayMc
MorganDoezn'tPlayMc Member
Messages:
4,666
Likes Received:
2,726
Trophy Points:
113
Hey there! Once again, I am here with another suggestion. Anyways, since being in the games lobby for a bit, I have seen that a lot of people spam,swear etc and most of the reports I see are in the games lobby. So what I am suggesting is that you install a plugin which makes it so that people are not able to spam and maybe give them a 5 second delay of speaking. I am only suggesting this for the games server because I don't see it being as needed in the others. I hope you all consider my suggestion and hopefully could be able to add it @halothe23 @rubik_cube_man @Lucariatias
2. HHyper
HHyper Member
Messages:
2,058
Likes Received:
238
Trophy Points:
138
I have seen alot of servers like hypixel have a 3 second delay for every vip?
3. Verdag
Verdag Member
Messages:
2,244
Likes Received:
539
Trophy Points:
113
Or even better,
Not having ANY warnings on people saying the same thing 5-7 times?
4. Story
Story Designer
Staff Member Designer
Messages:
3,488
Likes Received:
7,935
Trophy Points:
583
StorySays
Designer
PLUS
maybe It can count up all the times you have spammed and got warned for it and after 3 times you get banned? or muted?
Probably muted.
5. cheetos192
cheetos192 Member
Messages:
1,138
Likes Received:
131
Trophy Points:
113
cheetos192
Gold
Could be.
6. jtlg1234
jtlg1234 Member
Messages:
805
Likes Received:
141
Trophy Points:
43
I think that would help spam, but it could get annoying.
7. Verdag
Verdag Member
Messages:
2,244
Likes Received:
539
Trophy Points:
113
I like cheese!
*5 seconds later*
I like cheese!!
*Repeat with an additional !*
8. MorganDoezn'tPlayMc
MorganDoezn'tPlayMc Member
Messages:
4,666
Likes Received:
2,726
Trophy Points:
113
It would be better than what we have now.
9. Story
Story Designer
Staff Member Designer
Messages:
3,488
Likes Received:
7,935
Trophy Points:
583
StorySays
Designer
PLUS
Maybe for everything they say, have a delay like.
Player: HEY
*player then says a word right after*
You Can't type a message for more 2 seconds (or more)
Player: wanna Play Sg?
Most servers do this, Twitch.tv does this with chats, some of them
10. cocai
cocai Member
Messages:
1,127
Likes Received:
815
Trophy Points:
198
cocai
Emerald
I don't support this for when you need to speak to someone quickly. I'd rather have it the way it is.
11. Parvati12
Parvati12 Member
Messages:
1,313
Likes Received:
692
Trophy Points:
188
It would be pretty annoying not being able to talk every five seconds...
12. Oceanical
Oceanical Member
Messages:
4,646
Likes Received:
2,293
Trophy Points:
278
I say 2-3 seconds delay, not 5.. I don't think people could handle waiting 5 seconds.
13. Story
Story Designer
Staff Member Designer
Messages:
3,488
Likes Received:
7,935
Trophy Points:
583
StorySays
Designer
PLUS
Private Messaging can be done without spam.
They can easily do that
14. cheetos192
cheetos192 Member
Messages:
1,138
Likes Received:
131
Trophy Points:
113
cheetos192
Gold
I got spammed with msgs.
|
__label__pos
| 0.972541 |
(整理)用Elixir做一个多人扑克游戏 2
博客专区 > ljzn 的博客 > 博客详情
(整理)用Elixir做一个多人扑克游戏 2
ljzn 发表于1年前
(整理)用Elixir做一个多人扑克游戏 2
• 发表于 1年前
• 阅读 22
• 收藏 0
• 点赞 0
• 评论 0
腾讯云 新注册用户 域名抢购1元起>>>
摘要: 德州扑克
原文
现在我们已经做好了牌面大小的比较,游戏的流程,但还没有做玩家登陆,人数限制,甚至没有将奖金发送给赢家。接下来,让我们来完成它们。
玩家需要兑换游戏中的筹码才能开始游戏,在当不在游戏过程时,可以兑换筹码。
我们引入了两个新的进程。
银行
首先我们将建立一个银行,玩家可以在这里进行现金和筹码的相互转换。
银行GenServer会有两个API, deposit/2 和withdraw/2:
defmodule Poker.Bank do
use GenServer
def start_link do
GenServer.start_link(__MODULE__, [], name: __MODULE__)
end
def deposit(player, amount) do
GenServer.cast(__MODULE__, {:deposit, player, amount})
end
def withdraw(player, amount) do
GenServer.call(__MODULE__, {:withdraw, player, amount})
end
end
我们用模块名注册了这个进程,这样我们就不需要知道它的pid,就能进行访问了:
def init(_) do
{:ok, %{}}
end
def handle_cast({:deposit, player, amount}, state)
when amount >= 0 do
{
:noreply,
Map.update(state, player, amount, fn current ->
current + amount
end)
}
end
def handle_call({:withdraw, player, amount}, _from, state)
when amount >= 0 do
case Map.fetch(state, player) do
{:ok, current} when current >= amount ->
{:reply, :ok, Map.put(state, player, current - amount)}
_ ->
{:reply, {:error, :insufficient_funds}, state}
end
end
这段代码就显示了Elixir并发的威力,完全避免了竞态条件,因为是在同一个进程里执行的,所以所有操作会以队列来执行。
开桌
我们需要同时进行许多局独立的游戏。在玩家入座之后,可以兑换筹码或现金:
defmodule Poker.Table do
use GenServer
def start_link(num_seats) do
GenServer.start_link(__MODULE__, num_seats)
end
def sit(table, seat) do
GenServer.call(table, {:sit, seat})
end
def leave(table) do
GenServer.call(table, :leave)
end
def buy_in(table, amount) do
GenServer.call(table, {:buy_in, amount})
end
def cash_out(table) do
GenServer.call(table, :cash_out)
end
end
下面来实现GenServer的init/1:
def init(num_seats) do
players = :ets.new(:players, [:protected])
{:ok, %{hand: nil, players: players, num_seats: num_seats}}
end
我们用ETS来保存玩家的信息。对于sit 消息,我们是这样处理的:
def handle_call(
{:sit, seat}, _from, state = %{num_seats: last_seat}
) when seat < 1 or seat > last_seat do
{:reply, {:error, :seat_unavailable}, state}
end
def handle_call({:sit, seat}, {pid, _ref}) when is_integer(seat) do
{:reply, seat_player(state, pid, seat), state}
end
defp seat_player(%{players: players}, player, seat) do
case :ets.match_object(players, {:_, seat, :_}) do
[] ->
:ets.insert(players, {player, seat, 0})
:ok
_ -> {:error, :seat_taken}
end
end
leave 操作和 sit 正相反:
def handle_call(:leave, {pid, _ref}, state = %{hand: nil}) do
case get_player(state, pid) do
{:ok, %{balance: 0}} ->
unseat_player(state, pid)
{:reply, :ok, state}
{:ok, %{balance: balance}} when balance > 0 ->
{:reply, {:error, :player_has_balance}, state}
error -> {:reply, error, state}
end
end
defp get_player(state, player) do
case :ets.lookup(state.players, player) do
[] -> {:error, :not_at_table}
[tuple] -> {:ok, player_to_map(tuple)}
end
end
defp unseat_player(state, player) do
:ets.delete(state.players, player)
end
defp player_to_map({id, seat, balance}), do:
%{id: id, seat: seat, balance: balance}
在ETS中,所有数据都是元组形式,元组的第一个元素代表key。
买入和卖出
我们是这样实现 buy_in 的:
def handle_call(
{:buy_in, amount}, {pid, _ref}, state = %{hand: nil}
) when amount > 0 do
case state |> get_player(pid) |> withdraw_funds(amount) do
:ok ->
modify_balance(state, pid, amount)
{:reply, :ok, state}
error -> {:reply, error, state}
end
end
defp withdraw_funds({:ok, %{id: pid}}, amount), do:
Poker.Bank.withdraw(pid, amount)
defp withdraw_funds(error, _amount), do: error
defp modify_balance(state, player, delta) do
:ets.update_counter(state.players, player, {3, delta})
end
监控牌局
当牌局结束时,我们需要从hand状态切换出来,并把奖金给赢家。
首先我们需要实现deal命令, 用于开始新的一局:
def deal(table) do
GenServer.call(table, :deal)
end
def handle_call(:deal, _from, state = %{hand: nil}) do
players = get_players(state) |> Enum.map(&(&1.id))
case Poker.Hand.start(self, players) do
{:ok, hand} ->
Process.monitor(hand)
{:reply, {:ok, hand}, %{state | hand: hand}}
error ->
{:reply, error, state}
end
end
def handle_call(:deal, _from, state) do
{:reply, {:error, :hand_in_progress}, state}
end
在一局结束时我们会收到一个信息:
def handle_info(
{:DOWN, _ref, _type, hand, _reason}, state = %{hand: hand}
) do
{:noreply, %{state | hand: nil}}
end
通过向牌桌发送一个消息来更新玩家的钱包:
def update_balance(table, player, delta) do
GenServer.call(table, {:update_balance, player, delta})
end
def handle_call(
{:update_balance, player, delta}, {hand, _}, state = %{hand: hand}
) when delta < 0 do
case get_player(state, player) do
{:ok, %{balance: balance}} when balance + delta >= 0 ->
modify_balance(state, player, delta)
{:reply, :ok, state}
{:ok, _} -> {:reply, {:error, :insufficient_funds}, state}
error -> {:reply, error, state}
end
end
def handle_call({:update_balance, _, _}, _, state) do
{:reply, {:error, :invalid_hand}, state}
end
在下一章中,我们将应用Phoenix与Supervisor。
标签: Elixir
共有 人打赏支持
粉丝 27
博文 69
码字总数 96245
×
ljzn
如果觉得我的文章对您有用,请随意打赏。您的支持将鼓励我继续创作!
* 金额(元)
¥1 ¥5 ¥10 ¥20 其他金额
打赏人
留言
* 支付类型
微信扫码支付
打赏金额:
已支付成功
打赏金额:
|
__label__pos
| 0.897806 |
Browse Source
Remove deprecated keystone::auth options
Change-Id: Ic1764835e9c06623b1aef788485c9cfd9a01284f
changes/39/325039/1
Iury Gregory Melo Ferreira 6 years ago
parent
commit
01caa03b57
1. 116
manifests/keystone/auth.pp
2. 3
releasenotes/notes/remove_deprecated_keystone_auth_options-7702c56e6cc49f3c.yaml
3. 26
spec/classes/ceilometer_keystone_auth_spec.rb
116
manifests/keystone/auth.pp
@ -62,53 +62,6 @@
# This url should *not* contain any trailing '/'.
# Defaults to 'http://127.0.0.1:8777'.
#
# [*port*]
# (Optional) DEPRECATED: Use public_url, internal_url and admin_url instead.
# Setting this parameter overrides public_url, internal_url and admin_url parameters.
# Default port for endpoints.
# Defaults to 8777.
#
# [*public_protocol*]
# (Optional) DEPRECATED: Use public_url instead.
# Protocol for public endpoint.
# Setting this parameter overrides public_url parameter.
# Defaults to 'http'.
#
# [*public_address*]
# (Optional) DEPRECATED: Use public_url instead.
# Public address for endpoint.
# Setting this parameter overrides public_url parameter.
# Defaults to '127.0.0.1'.
#
# [*internal_protocol*]
# (Optional) DEPRECATED: Use internal_url instead.
# Protocol for internal endpoint.
# Setting this parameter overrides internal_url parameter.
# Defaults to 'http'.
#
# [*internal_address*]
# (Optional) DEPRECATED: Use internal_url instead.
# Internal address for endpoint.
# Setting this parameter overrides internal_url parameter.
# Defaults to '127.0.0.1'.
#
# [*admin_protocol*]
# (Optional) DEPRECATED: Use admin_url instead.
# Protocol for admin endpoint.
# Setting this parameter overrides admin_url parameter.
# Defaults to 'http'.
#
# [*admin_address*]
# (Optional) DEPRECATED: Use admin_url instead.
# Admin address for endpoint.
# Setting this parameter overrides admin_url parameter.
# Defaults to '127.0.0.1'.
#
# === Deprecation notes:
#
# If any value is provided for public_protocol, public_address or port parameters,
# public_url will be completely ignored. The same applies for internal and admin parameters.
#
# === Examples:
#
# class { 'ceilometer::keystone::auth':
@ -132,75 +85,12 @@ class ceilometer::keystone::auth (
$public_url = 'http://127.0.0.1:8777',
$admin_url = 'http://127.0.0.1:8777',
$internal_url = 'http://127.0.0.1:8777',
# DEPRECATED PARAMETERS
$port = undef,
$public_protocol = undef,
$public_address = undef,
$internal_protocol = undef,
$internal_address = undef,
$admin_protocol = undef,
$admin_address = undef,
) {
validate_string($password)
if $port {
warning('The port parameter is deprecated, use public_url, internal_url and admin_url instead.')
}
if $public_protocol {
warning('The public_protocol parameter is deprecated, use public_url instead.')
}
if $internal_protocol {
warning('The internal_protocol parameter is deprecated, use internal_url instead.')
}
if $admin_protocol {
warning('The admin_protocol parameter is deprecated, use admin_url instead.')
}
if $public_address {
warning('The public_address parameter is deprecated, use public_url instead.')
}
if $internal_address {
warning('The internal_address parameter is deprecated, use internal_url instead.')
}
if $admin_address {
warning('The admin_address parameter is deprecated, use admin_url instead.')
}
$service_name_real = pick($service_name, $auth_name)
if ($public_protocol or $public_address or $port) {
$public_url_real = sprintf('%s://%s:%s',
pick($public_protocol, 'http'),
pick($public_address, '127.0.0.1'),
pick($port, '8777'))
} else {
$public_url_real = $public_url
}
if ($admin_protocol or $admin_address or $port) {
$admin_url_real = sprintf('%s://%s:%s',
pick($admin_protocol, 'http'),
pick($admin_address, '127.0.0.1'),
pick($port, '8777'))
} else {
$admin_url_real = $admin_url
}
if ($internal_protocol or $internal_address or $port) {
$internal_url_real = sprintf('%s://%s:%s',
pick($internal_protocol, 'http'),
pick($internal_address, '127.0.0.1'),
pick($port, '8777'))
} else {
$internal_url_real = $internal_url
}
::keystone::resource::service_identity { $auth_name:
configure_user => $configure_user,
configure_user_role => $configure_user_role,
@ -213,9 +103,9 @@ class ceilometer::keystone::auth (
email => $email,
tenant => $tenant,
roles => ['admin', 'ResellerAdmin'],
public_url => $public_url_real,
admin_url => $admin_url_real,
internal_url => $internal_url_real,
public_url => $public_url,
admin_url => $admin_url,
internal_url => $internal_url,
}
if $configure_user_role {
3
releasenotes/notes/remove_deprecated_keystone_auth_options-7702c56e6cc49f3c.yaml
@ -0,0 +1,3 @@
---
other:
- Remove deprecated auth options for ::keystone::auth class
26
spec/classes/ceilometer_keystone_auth_spec.rb
@ -114,32 +114,6 @@ describe 'ceilometer::keystone::auth' do
end
end
context 'with deprecated parameters' do
before do
params.merge!({
:auth_name => 'mighty-ceilometer',
:region => 'RegionFortyTwo',
:public_address => '10.0.0.1',
:admin_address => '10.0.0.2',
:internal_address => '10.0.0.3',
:port => '65001',
:public_protocol => 'https',
:admin_protocol => 'ftp',
:internal_protocol => 'gopher',
:service_type => 'metering',
})
end
it 'configure ceilometer endpoints' do
is_expected.to contain_keystone_endpoint("#{params[:region]}/#{params[:auth_name]}::#{params[:service_type]}").with(
:ensure => 'present',
:public_url => "#{params[:public_protocol]}://#{params[:public_address]}:#{params[:port]}",
:admin_url => "#{params[:admin_protocol]}://#{params[:admin_address]}:#{params[:port]}",
:internal_url => "#{params[:internal_protocol]}://#{params[:internal_address]}:#{params[:port]}"
)
end
end
context 'when overriding service name' do
before do
params.merge!({
Loading…
Cancel
Save
|
__label__pos
| 0.999877 |
module FileUtils
Extended Modules
Defined in:
file_utils.cr
Instance Method Summary
Instance Method Detail
def cd(path : Path | String) #
Changes the current working directory of the process to the given string path.
require "file_utils"
FileUtils.cd("/tmp")
NOTE Alias of Dir.cd
[View source]
def cd(path : Path | String, &) #
Changes the current working directory of the process to the given string path and invoked the block, restoring the original working directory when the block exits.
require "file_utils"
FileUtils.cd("/tmp") { Dir.current } # => "/tmp"
NOTE Alias of Dir.cd with block
[View source]
def cmp(filename1 : Path | String, filename2 : Path | String) : Bool #
Compares two files filename1 to filename2 to determine if they are identical. Returns true if content are the same, false otherwise.
require "file_utils"
File.write("file.cr", "1")
File.write("bar.cr", "1")
FileUtils.cmp("file.cr", "bar.cr") # => true
NOTE Alias of File.same_content?
[View source]
def cp(src_path : Path | String, dest : Path | String) : Nil #
Copies the file src_path to the file or directory dest. If dest is a directory, a file with the same basename as src_path is created in dest Permission bits are copied too.
require "file_utils"
File.touch("afile")
File.chmod("afile", 0o600)
FileUtils.cp("afile", "afile_copy")
File.info("afile_copy").permissions.value # => 0o600
[View source]
def cp(srcs : Enumerable(Path | String), dest : Path | String) : Nil #
Copies a list of files src to dest. dest must be an existing directory.
require "file_utils"
Dir.mkdir("files")
FileUtils.cp({"bar.cr", "afile"}, "files")
[View source]
def cp_r(src_path : Path | String, dest_path : Path | String) : Nil #
Copies a file or directory src_path to dest_path. If src_path is a directory, this method copies all its contents recursively. If dest is a directory, copies src to dest/src.
require "file_utils"
FileUtils.cp_r("files", "dir")
[View source]
def ln(src_path : Path | String, dest_path : Path | String) #
Creates a hard link dest_path which points to src_path. If dest_path already exists and is a directory, creates a link dest_path/src_path.
require "file_utils"
# Create a hard link, pointing from /usr/bin/emacs to /usr/bin/vim
FileUtils.ln("/usr/bin/vim", "/usr/bin/emacs")
# Create a hard link, pointing from /tmp/foo.c to foo.c
FileUtils.ln("foo.c", "/tmp")
[View source]
def ln(src_paths : Enumerable(Path | String), dest_dir : Path | String) : Nil #
Creates a hard link to each path in src_paths inside the dest_dir directory. If dest_dir is not a directory, raises an ArgumentError.
require "file_utils"
# Create /usr/bin/vim, /usr/bin/emacs, and /usr/bin/nano as hard links
FileUtils.ln(["vim", "emacs", "nano"], "/usr/bin")
[View source]
def ln_s(src_path : Path | String, dest_path : Path | String) #
Creates a symbolic link dest_path which points to src_path. If dest_path already exists and is a directory, creates a link dest_path/src_path.
require "file_utils"
# Create a symbolic link pointing from logs to /var/log
FileUtils.ln_s("/var/log", "logs")
# Create a symbolic link pointing from /tmp/src to src
FileUtils.ln_s("src", "/tmp")
[View source]
def ln_s(src_paths : Enumerable(Path | String), dest_dir : Path | String) : Nil #
Creates a symbolic link to each path in src_paths inside the dest_dir directory. If dest_dir is not a directory, raises an ArgumentError.
require "file_utils"
# Create symbolic links in src/ pointing to every .c file in the current directory
FileUtils.ln_s(Dir["*.c"], "src")
[View source]
def ln_sf(src_path : Path | String, dest_path : Path | String) #
Like #ln_s(Path | String, Path | String), but overwrites dest_path if it exists and is not a directory or if dest_path/src_path exists.
require "file_utils"
# Create a symbolic link pointing from bar.c to foo.c, even if bar.c already exists
FileUtils.ln_sf("foo.c", "bar.c")
[View source]
def ln_sf(src_paths : Enumerable(Path | String), dest_dir : Path | String) : Nil #
Creates a symbolic link to each path in src_paths inside the dest_dir directory, ignoring any overwritten paths.
If dest_dir is not a directory, raises an ArgumentError.
require "file_utils"
# Create symbolic links in src/ pointing to every .c file in the current directory,
# even if it means overwriting files in src/
FileUtils.ln_sf(Dir["*.c"], "src")
[View source]
def mkdir(path : Path | String, mode = 511) : Nil #
Creates a new directory at the given path. The linux-style permission mode can be specified, with a default of 777 (0o777).
require "file_utils"
FileUtils.mkdir("src")
NOTE Alias of Dir.mkdir
[View source]
def mkdir(paths : Enumerable(Path | String), mode = 511) : Nil #
Creates a new directory at the given paths. The linux-style permission mode can be specified, with a default of 777 (0o777).
require "file_utils"
FileUtils.mkdir(["foo", "bar"])
[View source]
def mkdir_p(path : Path | String, mode = 511) : Nil #
Creates a new directory at the given path, including any non-existing intermediate directories. The linux-style permission mode can be specified, with a default of 777 (0o777).
require "file_utils"
FileUtils.mkdir_p("foo")
NOTE Alias of Dir.mkdir_p
[View source]
def mkdir_p(paths : Enumerable(Path | String), mode = 511) : Nil #
Creates a new directory at the given paths, including any non-existing intermediate directories. The linux-style permission mode can be specified, with a default of 777 (0o777).
require "file_utils"
FileUtils.mkdir_p(["foo", "bar", "baz", "dir1", "dir2", "dir3"])
[View source]
def mv(src_path : Path | String, dest_path : Path | String) : Nil #
Moves src_path to dest_path.
require "file_utils"
FileUtils.mv("afile", "afile.cr")
NOTE Alias of File.rename
[View source]
def mv(srcs : Enumerable(Path | String), dest : Path | String) : Nil #
Moves every srcs to dest.
require "file_utils"
FileUtils.mv(["foo", "bar"], "src")
[View source]
def pwd : String #
Returns the current working directory.
require "file_utils"
FileUtils.pwd
NOTE Alias of Dir.current
[View source]
def rm(path : Path | String) : Nil #
Deletes the path file given.
require "file_utils"
FileUtils.rm("afile.cr")
NOTE Alias of File.delete
[View source]
def rm(paths : Enumerable(Path | String)) : Nil #
Deletes all paths file given.
require "file_utils"
FileUtils.rm(["dir/afile", "afile_copy"])
[View source]
def rm_r(path : Path | String) : Nil #
Deletes a file or directory path. If path is a directory, this method removes all its contents recursively.
require "file_utils"
FileUtils.rm_r("dir")
FileUtils.rm_r("file.cr")
[View source]
def rm_r(paths : Enumerable(Path | String)) : Nil #
Deletes a list of files or directories paths. If one path is a directory, this method removes all its contents recursively.
require "file_utils"
FileUtils.rm_r(["files", "bar.cr"])
[View source]
def rm_rf(path : Path | String) : Nil #
Deletes a file or directory path. If path is a directory, this method removes all its contents recursively. Ignores all errors.
require "file_utils"
FileUtils.rm_rf("dir")
FileUtils.rm_rf("file.cr")
FileUtils.rm_rf("non_existent_file")
[View source]
def rm_rf(paths : Enumerable(Path | String)) : Nil #
Deletes a list of files or directories paths. If one path is a directory, this method removes all its contents recursively. Ignores all errors.
require "file_utils"
FileUtils.rm_rf(["dir", "file.cr", "non_existent_file"])
[View source]
def rmdir(path : Path | String) : Nil #
Removes the directory at the given path.
require "file_utils"
FileUtils.rmdir("baz")
NOTE Alias of Dir.rmdir
[View source]
def rmdir(paths : Enumerable(Path | String)) : Nil #
Removes all directories at the given paths.
require "file_utils"
FileUtils.rmdir(["dir1", "dir2", "dir3"])
[View source]
def touch(path : Path | String, time : Time = Time.utc) : Nil #
Attempts to set the access and modification times of the file named in the path parameter to the value given in time.
If the file does not exist, it will be created.
require "file_utils"
FileUtils.touch("afile.cr")
NOTE Alias of File.touch
[View source]
def touch(paths : Enumerable(Path | String), time : Time = Time.utc) : Nil #
Attempts to set the access and modification times of each file given in the paths parameter to the value given in time.
If the file does not exist, it will be created.
require "file_utils"
FileUtils.touch(["foo", "bar"])
[View source]
|
__label__pos
| 0.790892 |
Connect with us
Tech
Workday Function: How To Determine Work Finish Date In Excel
Excel WORKDAY formula – this time we will learn about how to determine the work end date.
Published
on
Workday Function
Photo: Shutterstock
Last Updated on June 10, 2022 by Mark D. Rio
Excel WORKDAY formula – this time we will learn about how to determine the work end date.
Actually, to find out the end date or the end date of work, we can just add the start date of work with the number of hours worked in units of days.
It’s just that if this calculation of the end of work excludes weekends or on Saturdays and Sundays the workers are off, then we will be a little confused to determine the number of weekend days (Saturday & Sunday) during the working period.
Not to mention if during this working period there are also several work days off other than weekends.
To determine the completion date of this work, Microsoft Excel provides the WORKDAY function .
In Microsoft Excel the Workday function is the opposite of the Networkdays function. If the Networkdays function returns the number of workdays in a given date range, the Workday function returns the date the work was completed.
If in the Networkday function the main parameter is the date of completion of the work, in the Workday function the main parameter used is the length of the work in days.
In the Workday formula, weekends are always Saturday and Sunday. If you use Microsoft Excel 2010 and above, this weekend parameter can also be set in more detail if you use WORKDAY.INTL function which has the same function.
To be clear, let’s talk more about how to use the Workday and Workday.Intl functions along with examples of their use.
Excel WORKDAY Function
The Excel WORKDAY function is used to return the serial number of the date before or after a specified number of working days excluding weekends and other dates specified as working holidays.
When using the workday formula, weekends are Saturdays and Sundays. If you intend to set another day as a working day off then use the Workday.Intl formula available in Microsoft Excel 2010 and above.
If you don’t want to ignore weekends and other holidays, you can simply add up the start date of work with the length of work in days. If the length of work is in months you can also use the Edate function.
How to Use the Workday Formula
To use the Workday function in excel formulas, the syntax or how to write it is as follows:
Code:
WORKDAY(Start_Date;Number_Days; [Holiday_Day])
Information
• Start_Date
Filled with work start date to be calculated.
• Number of days
Fill in the number of days the work is completed.
• [Holiday]
Is a data range or array constant that contains a date value that indicates the serial number of the date that will be excluded as workdays. This argument is optional so it can be left blank if there are no work holidays that will be ignored.
Example of Using the Workday Excel Formula
For an example of using the Workday formula in excel, please look at the following picture:
Code:
=WORKDAY(C2;D2)
In the first example of the excel formula above, the Workday function is used to find out the date of completion of work, where the start of work was on April 3, 2017 with 15 days of work.
In this formula, if you add the date directly to the number of working days, then the work completion date should be April 28, 2017. In the Workday formula, Saturdays and Sundays are not counted as effective working days, so the completion date for this work is April 28. 2017.
Code:
=WORKDAY(C3;D3;A2:A4)
In this second formula, apart from ignoring Saturday and Sunday, we also include other holidays, namely those in the A2:A4 range, so 15 working days after April 3, 2017 is April 26, 2017.
In the 3rd and 4th formulas:
Code:
=WORKDAY(C4;D4)
=WORKDAY(C5;D5;A2:A4)
The method of calculating the date also applies as before, only in these two excel formulas the value of the Amount_Day argument is filled with a minus number or less than 0 so that the date is counted backwards before the start date of work.
One of the shortcomings of this Workday function is the Weekend setting or weekends that are only Saturday and Sunday. If the calculation date that we use turns out to be a working holiday that is only used on Friday, for example, this function will not work as expected. For this reason, starting with the 2010 version of Microsoft Excel , more advanced functions have been added to replace this Workday function. The function in question is the Workday.Intl function .
Excel WORKDAY.INTL function
The WORKDAY.INTL function has basically the same function as the WORKDAY function , in that it is used to return the date before or after a certain day period, ignoring weekends and other holidays. It’s just that in this Workday.Intl function we can more freely determine which days we specify as weekends.
The WORKDAY.INTL function is only available for Microsoft Excel 2010 version and above.
How to Use the Workday.Intl Formula
The parameters or arguments of the Workday.Intl function are the same as the Workday functions, except that in this function there is an option to add the Weekend_Argument which is used to determine which days we will define as weekends or work holidays in each week.
The writing or syntax of the function is as follows:
Code:
WORKDAY.INTL(Start_Date;Number_Days; [Weekend]; [Holiday_Holidays])
Information:
• Start_Date
Filled with the start date of work to be calculated.
• Number of days
To be inputted with the number of days the work is completed.
• [Weekend]
Filled with weekend code that will be ignored from weekdays. This argument can be left blank (not used). If left blank, Workday.Intl will use Saturday and Sunday as weekends.
• [Holiday]
Is a data range or array constant that contains one or more serial numbers of work holidays. This argument is optional so it can be left blank if there are no work holidays that will be ignored.
There are 2 kinds of weekend codes in this function, in the form of numbers 1-17 or text string codes that indicate which days we will set as working days off in the week.
The numeric code for the Weekend parameter in the Workday.Intl function is as follows:
In addition to using the numeric code above, we can also set the weekend parameter with a seven-character text string in the form of a combination of the text numbers 1 and 0 representing Monday-Sunday. The number 1 represents holidays while the number 0 represents work days .
For example for weekends or holidays Saturday and Sunday the string code used is 0000011 . As for those who come to work only Monday, Tuesday and Thursday (Wednesday, Friday, Saturday and Sunday off) then the String code is 0010111 .
Example of Using the Workday.Intl excel Formula
An example of using the Workday.Intl formula is as follows:
Code:
=WORKDAY.INTL(C2;D2)
In this first formula the workday.Intl function will work exactly like the Workday formula where this formula calculates the work finish date starting on April 3 for 15 Days ignoring Saturday and Sunday. In this formula argument Weekends and Holidays us empty.
Code:
=WORKDAY.INTL(C2;D2;11)
In the second excel formula, we specify the Weekend argument with the number 11 which means that weekends fall only on Sundays, while the Holiday_Holiday argument we leave blank.
Code:
=WORKDAY.INTL(C2;D2;”0000001″;A2:A4)
In the 3rd formula, we use the string code to set the Weekend argument . We enter this string code enclosed by double quotes (“…”) to indicate that the data we enter is text.
Code:
=WORKDAY.INTL(C2;D2;;A2:A4)
For the last Workday.Intl example, we don’t use the Weekend_Parameter, which means that we set weekends by default, which are Saturdays and Sundays. In this formula, what needs to be considered is that if you use the Day_Holiday parameter without the Weekend_Parameter, then the writing method is like the example above, where the Day_holiday argument is written after 2 argument separators (;;) or (,,) if using the English setting.
Thus our discussion this time about how to determine the work completion date using the Workday and Workday.Intl functions.
If you find it useful, don’t hesitate to share it on the social media that you use so that more people can benefit. Greetings Excel Class.
Continue Reading
Click to comment
You must be logged in to post a comment Login
Leave a Reply
Trending
|
__label__pos
| 0.51792 |
Sheery Sheery - 2 months ago 41
Javascript Question
loop on a function in javascript?
Can we run a loop on a function in javascript, so that the function executes several times?
Answer
if you tired of using standard like (IF, WHILE), here is the another way of doing.. :)
you can use setTimeOut and clearTimeOut to execute functions in a certain interval. If you want to execute an function for a specific number of times, you still can acheive it by incrementing index and clearTimeOut as soon as your index reaches to certain point.
setTimeout() - executes a code some time in the future
clearTimeout() - cancels the setTimeout()
example from w3schools
<html>
<head>
<script type="text/javascript">
var c=0;
var t;
var timer_is_on=0;
function timedCount()
{
document.getElementById('txt').value=c;
c=c+1;
t=setTimeout("timedCount()",1000);
}
function doTimer()
{
if (!timer_is_on)
{
timer_is_on=1;
timedCount();
}
}
function stopCount()
{
clearTimeout(t);
timer_is_on=0;
}
</script>
</head>
<body>
<form>
<input type="button" value="Start count!" onClick="doTimer()">
<input type="text" id="txt">
<input type="button" value="Stop count!" onClick="stopCount()">
</form>
</body>
</html>
|
__label__pos
| 0.999923 |
ojus kulkarni ojus kulkarni - 6 months ago 54
AngularJS Question
How to use $http.successCallback response outside callback in angularJs
$scope.tempObject = {};
$http({
method: 'GET',
url: '/myRestUrl'
}).then(function successCallback(response) {
$scope.tempObject = response
console.log("Temp Object in successCallback ", $scope.tempObject);
}, function errorCallback(response) {
});
console.log("Temp Object outside $http ", $scope.tempObject);
I am getting response in
successCallback
but
not getting
$scope.tempObject
outside
$http
. its showing undefined.
How to access
response
or
$scope.tempObject
after
$http
Answer
But if I want to use $scope.tempObject after callback so how can I use it. ?
You need to chain from the httpPromise. Save the httpPromise and return the value to the onFullfilled handler function.
//save httpPromise for chaining
var httpPromise = $http({
method: 'GET',
url: '/myRestUrl'
}).then(function onFulfilledHandler(response) {
$scope.tempObject = response
console.log("Temp Object in successCallback ", $scope.tempObject);
//return object for chaining
return $scope.tempObject;
}, function errorCallback(response) {
});
Then outside you chain from the httpPromise.
httpPromise.then (function (tempObject) {
console.log("Temp Object outside $http ", tempObject);
});
For more information, see AngularJS $q Service API Reference -- chaining promises.
It is possible to create chains of any length and since a promise can be resolved with another promise (which will defer its resolution further), it is possible to pause/defer resolution of the promises at any point in the chain. This makes it possible to implement powerful APIs.1
Additional Resources
|
__label__pos
| 0.874477 |
Restrict passing through roundabouts during peak hours
Hi guys, I am using Graphhopper for my work, thanks for developing that.
Is it possible to count the number of roads connected by a roundabout and use that count to avoid or prioritize those roundabouts, especially during peak hours, as roundabouts with a higher number of intersecting roads often have a higher traffic congestion rate during peak hours?
Thank you.
Yes, this should be possible without too much work. You would probably create a new encoded value like NumberOfRoadsAtRoundabout where you store the number of such roads. Then you can use a custom model to reduce the priority of roundabouts where this value is high.
1 Like
This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.
|
__label__pos
| 0.95857 |
More
Data Visualization: Python Seaborn part 1
1. In the world of Analytics, the best way to get insights is by visualizing the data. We have already used Matplotlib, a 2D plotting library that allows us to plot different graphs and charts.
2. Another complimentary package that is based on data visualization library is Seaborn, which provide a higher level interface to draw statistical graphics.
Seaborn
• Is a python data visualization library for statistical plotting
• Is based on matplotlib (built on top of matplotlib)
• Is designed to work with NumPy and pandas data structures
• Provides a high-level interface for drawing attractive and informative statistical graphics.
• Comes equipped with preset styles and color palettes so you can create complex, aesthetically pleasing charts with a few lines of code.
Seaborn vs Matplotlib
Seaborn is built on top of Python’s core visualization library matplotlib, but it’s meant to serve as a complement, not a replacement.
• In most cases, we’ll still use matplotlib for simple plotting
• On Seaborn’s official website, they state: “If matplotlib “tries to make easy things easy and hard things possible”, seaborn tries to make a well-defined set of hard things easy too.
• Seaborn helps resolve the two major problems faced by Matplotlib, the problems are −
* • Default Matplotlib parameters
* • Working with data frames
In [ ]:
# Let's see the difference between codes of matplotlib and Seaborn
In [ ]:
# Matplotlib
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
x = np.linspace(0, 10, 1000)
plt.plot(x, np.sin(x), x, np.cos(x));
plt.show()
In [ ]:
# Seaborn
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
import seaborn as sns
sns.set()
x = np.linspace(0, 10, 1000)
# print(x)
plt.plot(x, np.sin(x), x, np.cos(x));
plt.show()
Data visualization using Seaborn
1. Visualizing statistical relationships
2. Visualizing categorical data
Visualizing statistical relationships (This can be also defined as relationship between variables)
The process of understanding relationships between variables of a dataset and how these relationships, in turn, depend on other variables is known as statistical analysis
relplot()
• This is a figure-level-function that makes use of two other axes functions for Visualizing Statistical Relationships which are –
* scatterplot()
* lineplot()
• By default it plots scatterplot()
In [ ]:
import seaborn as sns
import pandas as pd
import matplotlib.pyplot as plt
sns.set()
In [ ]:
df = sns.load_dataset('tips')
df.head()
Out[ ]:
total_billtipsexsmokerdaytimesize
016.991.01FemaleNoSunDinner2
110.341.66MaleNoSunDinner3
221.013.50MaleNoSunDinner3
323.683.31MaleNoSunDinner2
424.593.61FemaleNoSunDinner4
In [ ]:
df.tail()
Out[ ]:
total_billtipsexsmokerdaytimesize
23929.035.92MaleNoSatDinner3
24027.182.00FemaleYesSatDinner2
24122.672.00MaleYesSatDinner2
24217.821.75MaleNoSatDinner2
24318.783.00FemaleNoThurDinner2
In [ ]:
sns.relplot(x = 'total_bill', y = 'tip', data = df, kind = 'scatter')
plt.show() #that how there is direct relation between the food ordered and tip given.
In [ ]:
# We can also change kind to line.
sns.relplot(x = 'total_bill', y = 'tip', data = df, kind = 'line')
plt.show() #there is direct relation between the food ordered and tip given.
In [ ]:
# Parameters -
# • x, y
# • data
# • hue: It separtes the colour of dots with their types.
# • size
# • col: It can help to have different sex graphs.
# • style: They are used for showing differnt style of points.
In [ ]:
sns.relplot(x = 'total_bill', y = 'tip', data = df, hue = 'time')
plt.show() # By using hue we can see different time of lunch and dinner.
In [ ]:
sns.relplot(x = 'total_bill', y = 'tip', data = df, hue = 'time', style = 'sex')
plt.show() # By style we can see circle are male and x are female.
In [ ]:
sns.relplot(x = 'total_bill', y = 'tip', data = df, hue = 'time', col='sex')
plt.show() # col generated two differenet graphs when sex is male or female.
Let’s do the same with lines.
In [ ]:
import seaborn as sns
import pandas as pd
import matplotlib.pyplot as plt
sns.set()
In [ ]:
print(sns.get_dataset_names())
['anagrams', 'anscombe', 'attention', 'brain_networks', 'car_crashes', 'diamonds', 'dots', 'exercise', 'flights', 'fmri', 'gammas', 'geyser', 'iris', 'mpg', 'penguins', 'planets', 'tips', 'titanic']
In [ ]:
df = sns.load_dataset('flights')
df.head()
Out[ ]:
yearmonthpassengers
01949Jan112
11949Feb118
21949Mar132
31949Apr129
41949May121
In [ ]:
df.tail()
Out[ ]:
yearmonthpassengers
1391960Aug606
1401960Sep508
1411960Oct461
1421960Nov390
1431960Dec432
In [ ]:
sns.relplot(x = 'year', y = 'passengers', data = df, kind = 'line')
plt.show() # So the dark blue line gives us exact average and rest of the shade tells us the diversity at that point.
In [ ]:
sns.lineplot(x = 'year', y = 'passengers', data = df)
plt.show()
In [ ]:
sns.relplot(x = 'year', y = 'passengers', data = df, kind = 'line', hue = 'month')
plt.show()
In [ ]:
sns.relplot(x = 'year', y = 'passengers', data = df, kind = 'line',
col = 'month')
plt.show()
Recent Articles
Related Stories
BÌNH LUẬN
Vui lòng nhập bình luận của bạn
Vui lòng nhập tên của bạn ở đây
|
__label__pos
| 0.706287 |
String Tokenizer
I want to read from a text file which delimiters is tab and construct it as a SQL query string. I have problem when any of the field is empty.
StringTokenizer st = new StringTokenizer(thisLine, "\t"); while (st.hasMoreTokens()){
query = query + "\'" + st.nextToken() + "\'" ;
if(st.hasMoreTokens())
query = query + "," ;
// some other codes
}
mesg = "INSERT into Student_Result (STUID, AGE, SEX, RACE) "+ "values (" + query + ")";
If in the text file, any field is empty, the mesg string will be a problematic sql statement.
Thank you
cHEoAsked:
Who is Participating?
objectsConnect With a Mentor Commented:
Try something like:
String value = "";
StringTokenizer st = new StringTokenizer(thisLine, "\t", true); while (st.hasMoreTokens()){
String next = st.nextToken();
if (next.equals("\t"))
{
query = query + "\'" + value + "\'," ;
value = "";
}
else
{
value = next;
}
}
query += "\'" + value + "\'";
mesg = "INSERT into Student_Result (STUID, AGE, SEX, RACE) "+ "values (" + query + ")";
0
kotanCommented:
Try to use this,
StringTokenizer st = new StringTokenizer(thisLine, "\t", true);
This may solve ur problem but need some additional code..
0
cHEoAuthor Commented:
i tried before to use StringTokenizer(thisLine, "\t", true) but is having problem also. Can u provide me the additional code? thanks
0
7 new features that'll make your work life better
It’s our mission to create a product that solves the huge challenges you face at work every day. In case you missed it, here are 7 delightful things we've added recently to monday to make it even more awesome.
raid999Commented:
I am not sure if the is what you want but check if the tokens length is 0 then do what ever you wanan do.
0
cHEoAuthor Commented:
Objects, I was the one who personally sent email to ask you about other java problem. You are just fantastic. Thank a lot.
0
objectsCommented:
Happy to help :-)
http://www.objects.com.au
Brainbench MVP for Java 1
http://www.brainbench.com
0
Question has a verified solution.
Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.
Have a better answer? Share it in a comment.
All Courses
From novice to tech pro — start learning today.
|
__label__pos
| 0.885458 |
/* * gstvaapiparamspecs.c - GParamSpecs for some of our types * * gstreamer-vaapi (C) 2010 Splitted-Desktop Systems * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ /** * SECTION:gstvaapiparamspecs * @short_description: GParamSpecs for some of our types */ #include "config.h" #include #include "gstvaapiparamspecs.h" #include "gstvaapivalue.h" /* --- GstVaapiParamSpecID --- */ static void gst_vaapi_param_id_init(GParamSpec *pspec) { GST_VAAPI_PARAM_SPEC_ID(pspec)->default_value = VA_INVALID_ID; } static void gst_vaapi_param_id_set_default(GParamSpec *pspec, GValue *value) { gst_vaapi_value_set_id(value, GST_VAAPI_PARAM_SPEC_ID(pspec)->default_value); } static gboolean gst_vaapi_param_id_validate(GParamSpec *pspec, GValue *value) { /* Return FALSE if everything is OK, otherwise TRUE */ return FALSE; } static gint gst_vaapi_param_id_compare( GParamSpec *pspec, const GValue *value1, const GValue *value2 ) { const GstVaapiID v1 = gst_vaapi_value_get_id(value1); const GstVaapiID v2 = gst_vaapi_value_get_id(value2); return (v1 < v2 ? -1 : (v1 > v2 ? 1 : 0)); } GType gst_vaapi_param_spec_id_get_type(void) { static GType type; if (G_UNLIKELY(type == 0)) { static GParamSpecTypeInfo pspec_info = { sizeof(GstVaapiParamSpecID), /* instance_size */ 0, /* n_preallocs */ gst_vaapi_param_id_init, /* instance_init */ G_TYPE_INVALID, /* value_type */ NULL, /* finalize */ gst_vaapi_param_id_set_default, /* value_set_default */ gst_vaapi_param_id_validate, /* value_validate */ gst_vaapi_param_id_compare, /* values_cmp */ }; pspec_info.value_type = GST_VAAPI_TYPE_ID; type = g_param_type_register_static("GstVaapiParamSpecID", &pspec_info); } return type; } /** * gst_vaapi_param_spec_id: * @name: canonical name of the property specified * @nick: nick name for the property specified * @blurb: description of the property specified * @default_value: default value * @flags: flags for the property specified * * This function creates an ID GParamSpec for use by #GstVaapiObject * objects. This function is typically used in connection with * g_object_class_install_property() in a GObjects's instance_init * function. * * Return value: a newly created parameter specification */ GParamSpec * gst_vaapi_param_spec_id( const gchar *name, const gchar *nick, const gchar *blurb, GstVaapiID default_value, GParamFlags flags ) { GstVaapiParamSpecID *ispec; GParamSpec *pspec; GValue value = { 0, }; ispec = g_param_spec_internal( GST_VAAPI_TYPE_PARAM_ID, name, nick, blurb, flags ); if (!ispec) return NULL; ispec->default_value = default_value; pspec = G_PARAM_SPEC(ispec); /* Validate default value */ g_value_init(&value, GST_VAAPI_TYPE_ID); gst_vaapi_value_set_id(&value, default_value); if (gst_vaapi_param_id_validate(pspec, &value)) { g_param_spec_ref(pspec); g_param_spec_sink(pspec); g_param_spec_unref(pspec); pspec = NULL; } g_value_unset(&value); return pspec; }
|
__label__pos
| 0.980995 |
blob: 2db8bda43b6e6d8dd94d91526987b26e5954f290 [file] [log] [blame]
// SPDX-License-Identifier: GPL-2.0
/*
* Copyright (C) 1991, 1992 Linus Torvalds
* Copyright (C) 1994, Karl Keyte: Added support for disk statistics
* Elevator latency, (C) 2000 Andrea Arcangeli <[email protected]> SuSE
* Queue request tables / lock, selectable elevator, Jens Axboe <[email protected]>
* kernel-doc documentation started by NeilBrown <[email protected]>
* - July2000
* bio rewrite, highmem i/o, etc, Jens Axboe <[email protected]> - may 2001
*/
/*
* This handles all read/write requests to block devices
*/
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/backing-dev.h>
#include <linux/bio.h>
#include <linux/blkdev.h>
#include <linux/blk-mq.h>
#include <linux/highmem.h>
#include <linux/mm.h>
#include <linux/pagemap.h>
#include <linux/kernel_stat.h>
#include <linux/string.h>
#include <linux/init.h>
#include <linux/completion.h>
#include <linux/slab.h>
#include <linux/swap.h>
#include <linux/writeback.h>
#include <linux/task_io_accounting_ops.h>
#include <linux/fault-inject.h>
#include <linux/list_sort.h>
#include <linux/delay.h>
#include <linux/ratelimit.h>
#include <linux/pm_runtime.h>
#include <linux/blk-cgroup.h>
#include <linux/t10-pi.h>
#include <linux/debugfs.h>
#include <linux/bpf.h>
#include <linux/psi.h>
#include <linux/sched/sysctl.h>
#include <linux/blk-crypto.h>
#define CREATE_TRACE_POINTS
#include <trace/events/block.h>
#include "blk.h"
#include "blk-mq.h"
#include "blk-mq-sched.h"
#include "blk-pm.h"
#include "blk-rq-qos.h"
struct dentry *blk_debugfs_root;
EXPORT_TRACEPOINT_SYMBOL_GPL(block_bio_remap);
EXPORT_TRACEPOINT_SYMBOL_GPL(block_rq_remap);
EXPORT_TRACEPOINT_SYMBOL_GPL(block_bio_complete);
EXPORT_TRACEPOINT_SYMBOL_GPL(block_split);
EXPORT_TRACEPOINT_SYMBOL_GPL(block_unplug);
DEFINE_IDA(blk_queue_ida);
/*
* For queue allocation
*/
struct kmem_cache *blk_requestq_cachep;
/*
* Controlling structure to kblockd
*/
static struct workqueue_struct *kblockd_workqueue;
/**
* blk_queue_flag_set - atomically set a queue flag
* @flag: flag to be set
* @q: request queue
*/
void blk_queue_flag_set(unsigned int flag, struct request_queue *q)
{
set_bit(flag, &q->queue_flags);
}
EXPORT_SYMBOL(blk_queue_flag_set);
/**
* blk_queue_flag_clear - atomically clear a queue flag
* @flag: flag to be cleared
* @q: request queue
*/
void blk_queue_flag_clear(unsigned int flag, struct request_queue *q)
{
clear_bit(flag, &q->queue_flags);
}
EXPORT_SYMBOL(blk_queue_flag_clear);
/**
* blk_queue_flag_test_and_set - atomically test and set a queue flag
* @flag: flag to be set
* @q: request queue
*
* Returns the previous value of @flag - 0 if the flag was not set and 1 if
* the flag was already set.
*/
bool blk_queue_flag_test_and_set(unsigned int flag, struct request_queue *q)
{
return test_and_set_bit(flag, &q->queue_flags);
}
EXPORT_SYMBOL_GPL(blk_queue_flag_test_and_set);
void blk_rq_init(struct request_queue *q, struct request *rq)
{
memset(rq, 0, sizeof(*rq));
INIT_LIST_HEAD(&rq->queuelist);
rq->q = q;
rq->__sector = (sector_t) -1;
INIT_HLIST_NODE(&rq->hash);
RB_CLEAR_NODE(&rq->rb_node);
rq->tag = BLK_MQ_NO_TAG;
rq->internal_tag = BLK_MQ_NO_TAG;
rq->start_time_ns = ktime_get_ns();
rq->part = NULL;
refcount_set(&rq->ref, 1);
blk_crypto_rq_set_defaults(rq);
}
EXPORT_SYMBOL(blk_rq_init);
#define REQ_OP_NAME(name) [REQ_OP_##name] = #name
static const char *const blk_op_name[] = {
REQ_OP_NAME(READ),
REQ_OP_NAME(WRITE),
REQ_OP_NAME(FLUSH),
REQ_OP_NAME(DISCARD),
REQ_OP_NAME(SECURE_ERASE),
REQ_OP_NAME(ZONE_RESET),
REQ_OP_NAME(ZONE_RESET_ALL),
REQ_OP_NAME(ZONE_OPEN),
REQ_OP_NAME(ZONE_CLOSE),
REQ_OP_NAME(ZONE_FINISH),
REQ_OP_NAME(ZONE_APPEND),
REQ_OP_NAME(WRITE_SAME),
REQ_OP_NAME(WRITE_ZEROES),
REQ_OP_NAME(SCSI_IN),
REQ_OP_NAME(SCSI_OUT),
REQ_OP_NAME(DRV_IN),
REQ_OP_NAME(DRV_OUT),
};
#undef REQ_OP_NAME
/**
* blk_op_str - Return string XXX in the REQ_OP_XXX.
* @op: REQ_OP_XXX.
*
* Description: Centralize block layer function to convert REQ_OP_XXX into
* string format. Useful in the debugging and tracing bio or request. For
* invalid REQ_OP_XXX it returns string "UNKNOWN".
*/
inline const char *blk_op_str(unsigned int op)
{
const char *op_str = "UNKNOWN";
if (op < ARRAY_SIZE(blk_op_name) && blk_op_name[op])
op_str = blk_op_name[op];
return op_str;
}
EXPORT_SYMBOL_GPL(blk_op_str);
static const struct {
int errno;
const char *name;
} blk_errors[] = {
[BLK_STS_OK] = { 0, "" },
[BLK_STS_NOTSUPP] = { -EOPNOTSUPP, "operation not supported" },
[BLK_STS_TIMEOUT] = { -ETIMEDOUT, "timeout" },
[BLK_STS_NOSPC] = { -ENOSPC, "critical space allocation" },
[BLK_STS_TRANSPORT] = { -ENOLINK, "recoverable transport" },
[BLK_STS_TARGET] = { -EREMOTEIO, "critical target" },
[BLK_STS_NEXUS] = { -EBADE, "critical nexus" },
[BLK_STS_MEDIUM] = { -ENODATA, "critical medium" },
[BLK_STS_PROTECTION] = { -EILSEQ, "protection" },
[BLK_STS_RESOURCE] = { -ENOMEM, "kernel resource" },
[BLK_STS_DEV_RESOURCE] = { -EBUSY, "device resource" },
[BLK_STS_AGAIN] = { -EAGAIN, "nonblocking retry" },
/* device mapper special case, should not leak out: */
[BLK_STS_DM_REQUEUE] = { -EREMCHG, "dm internal retry" },
/* zone device specific errors */
[BLK_STS_ZONE_OPEN_RESOURCE] = { -ETOOMANYREFS, "open zones exceeded" },
[BLK_STS_ZONE_ACTIVE_RESOURCE] = { -EOVERFLOW, "active zones exceeded" },
/* everything else not covered above: */
[BLK_STS_IOERR] = { -EIO, "I/O" },
};
blk_status_t errno_to_blk_status(int errno)
{
int i;
for (i = 0; i < ARRAY_SIZE(blk_errors); i++) {
if (blk_errors[i].errno == errno)
return (__force blk_status_t)i;
}
return BLK_STS_IOERR;
}
EXPORT_SYMBOL_GPL(errno_to_blk_status);
int blk_status_to_errno(blk_status_t status)
{
int idx = (__force int)status;
if (WARN_ON_ONCE(idx >= ARRAY_SIZE(blk_errors)))
return -EIO;
return blk_errors[idx].errno;
}
EXPORT_SYMBOL_GPL(blk_status_to_errno);
static void print_req_error(struct request *req, blk_status_t status,
const char *caller)
{
int idx = (__force int)status;
if (WARN_ON_ONCE(idx >= ARRAY_SIZE(blk_errors)))
return;
printk_ratelimited(KERN_ERR
"%s: %s error, dev %s, sector %llu op 0x%x:(%s) flags 0x%x "
"phys_seg %u prio class %u\n",
caller, blk_errors[idx].name,
req->rq_disk ? req->rq_disk->disk_name : "?",
blk_rq_pos(req), req_op(req), blk_op_str(req_op(req)),
req->cmd_flags & ~REQ_OP_MASK,
req->nr_phys_segments,
IOPRIO_PRIO_CLASS(req->ioprio));
}
static void req_bio_endio(struct request *rq, struct bio *bio,
unsigned int nbytes, blk_status_t error)
{
if (error)
bio->bi_status = error;
if (unlikely(rq->rq_flags & RQF_QUIET))
bio_set_flag(bio, BIO_QUIET);
bio_advance(bio, nbytes);
if (req_op(rq) == REQ_OP_ZONE_APPEND && error == BLK_STS_OK) {
/*
* Partial zone append completions cannot be supported as the
* BIO fragments may end up not being written sequentially.
*/
if (bio->bi_iter.bi_size)
bio->bi_status = BLK_STS_IOERR;
else
bio->bi_iter.bi_sector = rq->__sector;
}
/* don't actually finish bio if it's part of flush sequence */
if (bio->bi_iter.bi_size == 0 && !(rq->rq_flags & RQF_FLUSH_SEQ))
bio_endio(bio);
}
void blk_dump_rq_flags(struct request *rq, char *msg)
{
printk(KERN_INFO "%s: dev %s: flags=%llx\n", msg,
rq->rq_disk ? rq->rq_disk->disk_name : "?",
(unsigned long long) rq->cmd_flags);
printk(KERN_INFO " sector %llu, nr/cnr %u/%u\n",
(unsigned long long)blk_rq_pos(rq),
blk_rq_sectors(rq), blk_rq_cur_sectors(rq));
printk(KERN_INFO " bio %p, biotail %p, len %u\n",
rq->bio, rq->biotail, blk_rq_bytes(rq));
}
EXPORT_SYMBOL(blk_dump_rq_flags);
/**
* blk_sync_queue - cancel any pending callbacks on a queue
* @q: the queue
*
* Description:
* The block layer may perform asynchronous callback activity
* on a queue, such as calling the unplug function after a timeout.
* A block device may call blk_sync_queue to ensure that any
* such activity is cancelled, thus allowing it to release resources
* that the callbacks might use. The caller must already have made sure
* that its ->submit_bio will not re-add plugging prior to calling
* this function.
*
* This function does not cancel any asynchronous activity arising
* out of elevator or throttling code. That would require elevator_exit()
* and blkcg_exit_queue() to be called with queue lock initialized.
*
*/
void blk_sync_queue(struct request_queue *q)
{
del_timer_sync(&q->timeout);
cancel_work_sync(&q->timeout_work);
}
EXPORT_SYMBOL(blk_sync_queue);
/**
* blk_set_pm_only - increment pm_only counter
* @q: request queue pointer
*/
void blk_set_pm_only(struct request_queue *q)
{
atomic_inc(&q->pm_only);
}
EXPORT_SYMBOL_GPL(blk_set_pm_only);
void blk_clear_pm_only(struct request_queue *q)
{
int pm_only;
pm_only = atomic_dec_return(&q->pm_only);
WARN_ON_ONCE(pm_only < 0);
if (pm_only == 0)
wake_up_all(&q->mq_freeze_wq);
}
EXPORT_SYMBOL_GPL(blk_clear_pm_only);
/**
* blk_put_queue - decrement the request_queue refcount
* @q: the request_queue structure to decrement the refcount for
*
* Decrements the refcount of the request_queue kobject. When this reaches 0
* we'll have blk_release_queue() called.
*
* Context: Any context, but the last reference must not be dropped from
* atomic context.
*/
void blk_put_queue(struct request_queue *q)
{
kobject_put(&q->kobj);
}
EXPORT_SYMBOL(blk_put_queue);
void blk_set_queue_dying(struct request_queue *q)
{
blk_queue_flag_set(QUEUE_FLAG_DYING, q);
/*
* When queue DYING flag is set, we need to block new req
* entering queue, so we call blk_freeze_queue_start() to
* prevent I/O from crossing blk_queue_enter().
*/
blk_freeze_queue_start(q);
if (queue_is_mq(q))
blk_mq_wake_waiters(q);
/* Make blk_queue_enter() reexamine the DYING flag. */
wake_up_all(&q->mq_freeze_wq);
}
EXPORT_SYMBOL_GPL(blk_set_queue_dying);
/**
* blk_cleanup_queue - shutdown a request queue
* @q: request queue to shutdown
*
* Mark @q DYING, drain all pending requests, mark @q DEAD, destroy and
* put it. All future requests will be failed immediately with -ENODEV.
*
* Context: can sleep
*/
void blk_cleanup_queue(struct request_queue *q)
{
/* cannot be called from atomic context */
might_sleep();
WARN_ON_ONCE(blk_queue_registered(q));
/* mark @q DYING, no new request or merges will be allowed afterwards */
blk_set_queue_dying(q);
blk_queue_flag_set(QUEUE_FLAG_NOMERGES, q);
blk_queue_flag_set(QUEUE_FLAG_NOXMERGES, q);
/*
* Drain all requests queued before DYING marking. Set DEAD flag to
* prevent that blk_mq_run_hw_queues() accesses the hardware queues
* after draining finished.
*/
blk_freeze_queue(q);
rq_qos_exit(q);
blk_queue_flag_set(QUEUE_FLAG_DEAD, q);
/* for synchronous bio-based driver finish in-flight integrity i/o */
blk_flush_integrity();
/* @q won't process any more request, flush async actions */
del_timer_sync(&q->backing_dev_info->laptop_mode_wb_timer);
blk_sync_queue(q);
if (queue_is_mq(q))
blk_mq_exit_queue(q);
/*
* In theory, request pool of sched_tags belongs to request queue.
* However, the current implementation requires tag_set for freeing
* requests, so free the pool now.
*
* Queue has become frozen, there can't be any in-queue requests, so
* it is safe to free requests now.
*/
mutex_lock(&q->sysfs_lock);
if (q->elevator)
blk_mq_sched_free_requests(q);
mutex_unlock(&q->sysfs_lock);
percpu_ref_exit(&q->q_usage_counter);
/* @q is and will stay empty, shutdown and put */
blk_put_queue(q);
}
EXPORT_SYMBOL(blk_cleanup_queue);
/**
* blk_queue_enter() - try to increase q->q_usage_counter
* @q: request queue pointer
* @flags: BLK_MQ_REQ_NOWAIT and/or BLK_MQ_REQ_PREEMPT
*/
int blk_queue_enter(struct request_queue *q, blk_mq_req_flags_t flags)
{
const bool pm = flags & BLK_MQ_REQ_PREEMPT;
while (true) {
bool success = false;
rcu_read_lock();
if (percpu_ref_tryget_live(&q->q_usage_counter)) {
/*
* The code that increments the pm_only counter is
* responsible for ensuring that that counter is
* globally visible before the queue is unfrozen.
*/
if (pm || !blk_queue_pm_only(q)) {
success = true;
} else {
percpu_ref_put(&q->q_usage_counter);
}
}
rcu_read_unlock();
if (success)
return 0;
if (flags & BLK_MQ_REQ_NOWAIT)
return -EBUSY;
/*
* read pair of barrier in blk_freeze_queue_start(),
* we need to order reading __PERCPU_REF_DEAD flag of
* .q_usage_counter and reading .mq_freeze_depth or
* queue dying flag, otherwise the following wait may
* never return if the two reads are reordered.
*/
smp_rmb();
wait_event(q->mq_freeze_wq,
(!q->mq_freeze_depth &&
(pm || (blk_pm_request_resume(q),
!blk_queue_pm_only(q)))) ||
blk_queue_dying(q));
if (blk_queue_dying(q))
return -ENODEV;
}
}
static inline int bio_queue_enter(struct bio *bio)
{
struct request_queue *q = bio->bi_disk->queue;
bool nowait = bio->bi_opf & REQ_NOWAIT;
int ret;
ret = blk_queue_enter(q, nowait ? BLK_MQ_REQ_NOWAIT : 0);
if (unlikely(ret)) {
if (nowait && !blk_queue_dying(q))
bio_wouldblock_error(bio);
else
bio_io_error(bio);
}
return ret;
}
void blk_queue_exit(struct request_queue *q)
{
percpu_ref_put(&q->q_usage_counter);
}
static void blk_queue_usage_counter_release(struct percpu_ref *ref)
{
struct request_queue *q =
container_of(ref, struct request_queue, q_usage_counter);
wake_up_all(&q->mq_freeze_wq);
}
static void blk_rq_timed_out_timer(struct timer_list *t)
{
struct request_queue *q = from_timer(q, t, timeout);
kblockd_schedule_work(&q->timeout_work);
}
static void blk_timeout_work(struct work_struct *work)
{
}
struct request_queue *blk_alloc_queue(int node_id)
{
struct request_queue *q;
int ret;
q = kmem_cache_alloc_node(blk_requestq_cachep,
GFP_KERNEL | __GFP_ZERO, node_id);
if (!q)
return NULL;
q->last_merge = NULL;
q->id = ida_simple_get(&blk_queue_ida, 0, 0, GFP_KERNEL);
if (q->id < 0)
goto fail_q;
ret = bioset_init(&q->bio_split, BIO_POOL_SIZE, 0, BIOSET_NEED_BVECS);
if (ret)
goto fail_id;
q->backing_dev_info = bdi_alloc(node_id);
if (!q->backing_dev_info)
goto fail_split;
q->stats = blk_alloc_queue_stats();
if (!q->stats)
goto fail_stats;
q->node = node_id;
atomic_set(&q->nr_active_requests_shared_sbitmap, 0);
timer_setup(&q->backing_dev_info->laptop_mode_wb_timer,
laptop_mode_timer_fn, 0);
timer_setup(&q->timeout, blk_rq_timed_out_timer, 0);
INIT_WORK(&q->timeout_work, blk_timeout_work);
INIT_LIST_HEAD(&q->icq_list);
#ifdef CONFIG_BLK_CGROUP
INIT_LIST_HEAD(&q->blkg_list);
#endif
kobject_init(&q->kobj, &blk_queue_ktype);
mutex_init(&q->debugfs_mutex);
mutex_init(&q->sysfs_lock);
mutex_init(&q->sysfs_dir_lock);
spin_lock_init(&q->queue_lock);
init_waitqueue_head(&q->mq_freeze_wq);
mutex_init(&q->mq_freeze_lock);
/*
* Init percpu_ref in atomic mode so that it's faster to shutdown.
* See blk_register_queue() for details.
*/
if (percpu_ref_init(&q->q_usage_counter,
blk_queue_usage_counter_release,
PERCPU_REF_INIT_ATOMIC, GFP_KERNEL))
goto fail_bdi;
if (blkcg_init_queue(q))
goto fail_ref;
blk_queue_dma_alignment(q, 511);
blk_set_default_limits(&q->limits);
q->nr_requests = BLKDEV_MAX_RQ;
return q;
fail_ref:
percpu_ref_exit(&q->q_usage_counter);
fail_bdi:
blk_free_queue_stats(q->stats);
fail_stats:
bdi_put(q->backing_dev_info);
fail_split:
bioset_exit(&q->bio_split);
fail_id:
ida_simple_remove(&blk_queue_ida, q->id);
fail_q:
kmem_cache_free(blk_requestq_cachep, q);
return NULL;
}
EXPORT_SYMBOL(blk_alloc_queue);
/**
* blk_get_queue - increment the request_queue refcount
* @q: the request_queue structure to increment the refcount for
*
* Increment the refcount of the request_queue kobject.
*
* Context: Any context.
*/
bool blk_get_queue(struct request_queue *q)
{
if (likely(!blk_queue_dying(q))) {
__blk_get_queue(q);
return true;
}
return false;
}
EXPORT_SYMBOL(blk_get_queue);
/**
* blk_get_request - allocate a request
* @q: request queue to allocate a request for
* @op: operation (REQ_OP_*) and REQ_* flags, e.g. REQ_SYNC.
* @flags: BLK_MQ_REQ_* flags, e.g. BLK_MQ_REQ_NOWAIT.
*/
struct request *blk_get_request(struct request_queue *q, unsigned int op,
blk_mq_req_flags_t flags)
{
struct request *req;
WARN_ON_ONCE(op & REQ_NOWAIT);
WARN_ON_ONCE(flags & ~(BLK_MQ_REQ_NOWAIT | BLK_MQ_REQ_PREEMPT));
req = blk_mq_alloc_request(q, op, flags);
if (!IS_ERR(req) && q->mq_ops->initialize_rq_fn)
q->mq_ops->initialize_rq_fn(req);
return req;
}
EXPORT_SYMBOL(blk_get_request);
void blk_put_request(struct request *req)
{
blk_mq_free_request(req);
}
EXPORT_SYMBOL(blk_put_request);
static void handle_bad_sector(struct bio *bio, sector_t maxsector)
{
char b[BDEVNAME_SIZE];
pr_info_ratelimited("attempt to access beyond end of device\n"
"%s: rw=%d, want=%llu, limit=%llu\n",
bio_devname(bio, b), bio->bi_opf,
bio_end_sector(bio), maxsector);
}
#ifdef CONFIG_FAIL_MAKE_REQUEST
static DECLARE_FAULT_ATTR(fail_make_request);
static int __init setup_fail_make_request(char *str)
{
return setup_fault_attr(&fail_make_request, str);
}
__setup("fail_make_request=", setup_fail_make_request);
static bool should_fail_request(struct hd_struct *part, unsigned int bytes)
{
return part->make_it_fail && should_fail(&fail_make_request, bytes);
}
static int __init fail_make_request_debugfs(void)
{
struct dentry *dir = fault_create_debugfs_attr("fail_make_request",
NULL, &fail_make_request);
return PTR_ERR_OR_ZERO(dir);
}
late_initcall(fail_make_request_debugfs);
#else /* CONFIG_FAIL_MAKE_REQUEST */
static inline bool should_fail_request(struct hd_struct *part,
unsigned int bytes)
{
return false;
}
#endif /* CONFIG_FAIL_MAKE_REQUEST */
static inline bool bio_check_ro(struct bio *bio, struct hd_struct *part)
{
const int op = bio_op(bio);
if (part->policy && op_is_write(op)) {
char b[BDEVNAME_SIZE];
if (op_is_flush(bio->bi_opf) && !bio_sectors(bio))
return false;
WARN_ONCE(1,
"Trying to write to read-only block-device %s (partno %d)\n",
bio_devname(bio, b), part->partno);
/* Older lvm-tools actually trigger this */
return false;
}
return false;
}
static noinline int should_fail_bio(struct bio *bio)
{
if (should_fail_request(&bio->bi_disk->part0, bio->bi_iter.bi_size))
return -EIO;
return 0;
}
ALLOW_ERROR_INJECTION(should_fail_bio, ERRNO);
/*
* Check whether this bio extends beyond the end of the device or partition.
* This may well happen - the kernel calls bread() without checking the size of
* the device, e.g., when mounting a file system.
*/
static inline int bio_check_eod(struct bio *bio, sector_t maxsector)
{
unsigned int nr_sectors = bio_sectors(bio);
if (nr_sectors && maxsector &&
(nr_sectors > maxsector ||
bio->bi_iter.bi_sector > maxsector - nr_sectors)) {
handle_bad_sector(bio, maxsector);
return -EIO;
}
return 0;
}
/*
* Remap block n of partition p to block n+start(p) of the disk.
*/
static inline int blk_partition_remap(struct bio *bio)
{
struct hd_struct *p;
int ret = -EIO;
rcu_read_lock();
p = __disk_get_part(bio->bi_disk, bio->bi_partno);
if (unlikely(!p))
goto out;
if (unlikely(should_fail_request(p, bio->bi_iter.bi_size)))
goto out;
if (unlikely(bio_check_ro(bio, p)))
goto out;
if (bio_sectors(bio)) {
if (bio_check_eod(bio, part_nr_sects_read(p)))
goto out;
bio->bi_iter.bi_sector += p->start_sect;
trace_block_bio_remap(bio->bi_disk->queue, bio, part_devt(p),
bio->bi_iter.bi_sector - p->start_sect);
}
bio->bi_partno = 0;
ret = 0;
out:
rcu_read_unlock();
return ret;
}
/*
* Check write append to a zoned block device.
*/
static inline blk_status_t blk_check_zone_append(struct request_queue *q,
struct bio *bio)
{
sector_t pos = bio->bi_iter.bi_sector;
int nr_sectors = bio_sectors(bio);
/* Only applicable to zoned block devices */
if (!blk_queue_is_zoned(q))
return BLK_STS_NOTSUPP;
/* The bio sector must point to the start of a sequential zone */
if (pos & (blk_queue_zone_sectors(q) - 1) ||
!blk_queue_zone_is_seq(q, pos))
return BLK_STS_IOERR;
/*
* Not allowed to cross zone boundaries. Otherwise, the BIO will be
* split and could result in non-contiguous sectors being written in
* different zones.
*/
if (nr_sectors > q->limits.chunk_sectors)
return BLK_STS_IOERR;
/* Make sure the BIO is small enough and will not get split */
if (nr_sectors > q->limits.max_zone_append_sectors)
return BLK_STS_IOERR;
bio->bi_opf |= REQ_NOMERGE;
return BLK_STS_OK;
}
static noinline_for_stack bool submit_bio_checks(struct bio *bio)
{
struct request_queue *q = bio->bi_disk->queue;
blk_status_t status = BLK_STS_IOERR;
struct blk_plug *plug;
might_sleep();
plug = blk_mq_plug(q, bio);
if (plug && plug->nowait)
bio->bi_opf |= REQ_NOWAIT;
/*
* For a REQ_NOWAIT based request, return -EOPNOTSUPP
* if queue does not support NOWAIT.
*/
if ((bio->bi_opf & REQ_NOWAIT) && !blk_queue_nowait(q))
goto not_supported;
if (should_fail_bio(bio))
goto end_io;
if (bio->bi_partno) {
if (unlikely(blk_partition_remap(bio)))
goto end_io;
} else {
if (unlikely(bio_check_ro(bio, &bio->bi_disk->part0)))
goto end_io;
if (unlikely(bio_check_eod(bio, get_capacity(bio->bi_disk))))
goto end_io;
}
/*
* Filter flush bio's early so that bio based drivers without flush
* support don't have to worry about them.
*/
if (op_is_flush(bio->bi_opf) &&
!test_bit(QUEUE_FLAG_WC, &q->queue_flags)) {
bio->bi_opf &= ~(REQ_PREFLUSH | REQ_FUA);
if (!bio_sectors(bio)) {
status = BLK_STS_OK;
goto end_io;
}
}
if (!test_bit(QUEUE_FLAG_POLL, &q->queue_flags))
bio->bi_opf &= ~REQ_HIPRI;
switch (bio_op(bio)) {
case REQ_OP_DISCARD:
if (!blk_queue_discard(q))
goto not_supported;
break;
case REQ_OP_SECURE_ERASE:
if (!blk_queue_secure_erase(q))
goto not_supported;
break;
case REQ_OP_WRITE_SAME:
if (!q->limits.max_write_same_sectors)
goto not_supported;
break;
case REQ_OP_ZONE_APPEND:
status = blk_check_zone_append(q, bio);
if (status != BLK_STS_OK)
goto end_io;
break;
case REQ_OP_ZONE_RESET:
case REQ_OP_ZONE_OPEN:
case REQ_OP_ZONE_CLOSE:
case REQ_OP_ZONE_FINISH:
if (!blk_queue_is_zoned(q))
goto not_supported;
break;
case REQ_OP_ZONE_RESET_ALL:
if (!blk_queue_is_zoned(q) || !blk_queue_zone_resetall(q))
goto not_supported;
break;
case REQ_OP_WRITE_ZEROES:
if (!q->limits.max_write_zeroes_sectors)
goto not_supported;
break;
default:
break;
}
/*
* Various block parts want %current->io_context, so allocate it up
* front rather than dealing with lots of pain to allocate it only
* where needed. This may fail and the block layer knows how to live
* with it.
*/
if (unlikely(!current->io_context))
create_task_io_context(current, GFP_ATOMIC, q->node);
if (blk_throtl_bio(bio)) {
blkcg_bio_issue_init(bio);
return false;
}
blk_cgroup_bio_start(bio);
blkcg_bio_issue_init(bio);
if (!bio_flagged(bio, BIO_TRACE_COMPLETION)) {
trace_block_bio_queue(q, bio);
/* Now that enqueuing has been traced, we need to trace
* completion as well.
*/
bio_set_flag(bio, BIO_TRACE_COMPLETION);
}
return true;
not_supported:
status = BLK_STS_NOTSUPP;
end_io:
bio->bi_status = status;
bio_endio(bio);
return false;
}
static blk_qc_t __submit_bio(struct bio *bio)
{
struct gendisk *disk = bio->bi_disk;
blk_qc_t ret = BLK_QC_T_NONE;
if (blk_crypto_bio_prep(&bio)) {
if (!disk->fops->submit_bio)
return blk_mq_submit_bio(bio);
ret = disk->fops->submit_bio(bio);
}
blk_queue_exit(disk->queue);
return ret;
}
/*
* The loop in this function may be a bit non-obvious, and so deserves some
* explanation:
*
* - Before entering the loop, bio->bi_next is NULL (as all callers ensure
* that), so we have a list with a single bio.
* - We pretend that we have just taken it off a longer list, so we assign
* bio_list to a pointer to the bio_list_on_stack, thus initialising the
* bio_list of new bios to be added. ->submit_bio() may indeed add some more
* bios through a recursive call to submit_bio_noacct. If it did, we find a
* non-NULL value in bio_list and re-enter the loop from the top.
* - In this case we really did just take the bio of the top of the list (no
* pretending) and so remove it from bio_list, and call into ->submit_bio()
* again.
*
* bio_list_on_stack[0] contains bios submitted by the current ->submit_bio.
* bio_list_on_stack[1] contains bios that were submitted before the current
* ->submit_bio_bio, but that haven't been processed yet.
*/
static blk_qc_t __submit_bio_noacct(struct bio *bio)
{
struct bio_list bio_list_on_stack[2];
blk_qc_t ret = BLK_QC_T_NONE;
BUG_ON(bio->bi_next);
bio_list_init(&bio_list_on_stack[0]);
current->bio_list = bio_list_on_stack;
do {
struct request_queue *q = bio->bi_disk->queue;
struct bio_list lower, same;
if (unlikely(bio_queue_enter(bio) != 0))
continue;
/*
* Create a fresh bio_list for all subordinate requests.
*/
bio_list_on_stack[1] = bio_list_on_stack[0];
bio_list_init(&bio_list_on_stack[0]);
ret = __submit_bio(bio);
/*
* Sort new bios into those for a lower level and those for the
* same level.
*/
bio_list_init(&lower);
bio_list_init(&same);
while ((bio = bio_list_pop(&bio_list_on_stack[0])) != NULL)
if (q == bio->bi_disk->queue)
bio_list_add(&same, bio);
else
bio_list_add(&lower, bio);
/*
* Now assemble so we handle the lowest level first.
*/
bio_list_merge(&bio_list_on_stack[0], &lower);
bio_list_merge(&bio_list_on_stack[0], &same);
bio_list_merge(&bio_list_on_stack[0], &bio_list_on_stack[1]);
} while ((bio = bio_list_pop(&bio_list_on_stack[0])));
current->bio_list = NULL;
return ret;
}
static blk_qc_t __submit_bio_noacct_mq(struct bio *bio)
{
struct bio_list bio_list[2] = { };
blk_qc_t ret = BLK_QC_T_NONE;
current->bio_list = bio_list;
do {
struct gendisk *disk = bio->bi_disk;
if (unlikely(bio_queue_enter(bio) != 0))
continue;
if (!blk_crypto_bio_prep(&bio)) {
blk_queue_exit(disk->queue);
ret = BLK_QC_T_NONE;
continue;
}
ret = blk_mq_submit_bio(bio);
} while ((bio = bio_list_pop(&bio_list[0])));
current->bio_list = NULL;
return ret;
}
/**
* submit_bio_noacct - re-submit a bio to the block device layer for I/O
* @bio: The bio describing the location in memory and on the device.
*
* This is a version of submit_bio() that shall only be used for I/O that is
* resubmitted to lower level drivers by stacking block drivers. All file
* systems and other upper level users of the block layer should use
* submit_bio() instead.
*/
blk_qc_t submit_bio_noacct(struct bio *bio)
{
if (!submit_bio_checks(bio))
return BLK_QC_T_NONE;
/*
* We only want one ->submit_bio to be active at a time, else stack
* usage with stacked devices could be a problem. Use current->bio_list
* to collect a list of requests submited by a ->submit_bio method while
* it is active, and then process them after it returned.
*/
if (current->bio_list) {
bio_list_add(¤t->bio_list[0], bio);
return BLK_QC_T_NONE;
}
if (!bio->bi_disk->fops->submit_bio)
return __submit_bio_noacct_mq(bio);
return __submit_bio_noacct(bio);
}
EXPORT_SYMBOL(submit_bio_noacct);
/**
* submit_bio - submit a bio to the block device layer for I/O
* @bio: The &struct bio which describes the I/O
*
* submit_bio() is used to submit I/O requests to block devices. It is passed a
* fully set up &struct bio that describes the I/O that needs to be done. The
* bio will be send to the device described by the bi_disk and bi_partno fields.
*
* The success/failure status of the request, along with notification of
* completion, is delivered asynchronously through the ->bi_end_io() callback
* in @bio. The bio must NOT be touched by thecaller until ->bi_end_io() has
* been called.
*/
blk_qc_t submit_bio(struct bio *bio)
{
if (blkcg_punt_bio_submit(bio))
return BLK_QC_T_NONE;
/*
* If it's a regular read/write or a barrier with data attached,
* go through the normal accounting stuff before submission.
*/
if (bio_has_data(bio)) {
unsigned int count;
if (unlikely(bio_op(bio) == REQ_OP_WRITE_SAME))
count = queue_logical_block_size(bio->bi_disk->queue) >> 9;
else
count = bio_sectors(bio);
if (op_is_write(bio_op(bio))) {
count_vm_events(PGPGOUT, count);
} else {
task_io_account_read(bio->bi_iter.bi_size);
count_vm_events(PGPGIN, count);
}
if (unlikely(block_dump)) {
char b[BDEVNAME_SIZE];
printk(KERN_DEBUG "%s(%d): %s block %Lu on %s (%u sectors)\n",
current->comm, task_pid_nr(current),
op_is_write(bio_op(bio)) ? "WRITE" : "READ",
(unsigned long long)bio->bi_iter.bi_sector,
bio_devname(bio, b), count);
}
}
/*
* If we're reading data that is part of the userspace workingset, count
* submission time as memory stall. When the device is congested, or
* the submitting cgroup IO-throttled, submission can be a significant
* part of overall IO time.
*/
if (unlikely(bio_op(bio) == REQ_OP_READ &&
bio_flagged(bio, BIO_WORKINGSET))) {
unsigned long pflags;
blk_qc_t ret;
psi_memstall_enter(&pflags);
ret = submit_bio_noacct(bio);
psi_memstall_leave(&pflags);
return ret;
}
return submit_bio_noacct(bio);
}
EXPORT_SYMBOL(submit_bio);
/**
* blk_cloned_rq_check_limits - Helper function to check a cloned request
* for the new queue limits
* @q: the queue
* @rq: the request being checked
*
* Description:
* @rq may have been made based on weaker limitations of upper-level queues
* in request stacking drivers, and it may violate the limitation of @q.
* Since the block layer and the underlying device driver trust @rq
* after it is inserted to @q, it should be checked against @q before
* the insertion using this generic function.
*
* Request stacking drivers like request-based dm may change the queue
* limits when retrying requests on other queues. Those requests need
* to be checked against the new queue limits again during dispatch.
*/
static blk_status_t blk_cloned_rq_check_limits(struct request_queue *q,
struct request *rq)
{
unsigned int max_sectors = blk_queue_get_max_sectors(q, req_op(rq));
if (blk_rq_sectors(rq) > max_sectors) {
/*
* SCSI device does not have a good way to return if
* Write Same/Zero is actually supported. If a device rejects
* a non-read/write command (discard, write same,etc.) the
* low-level device driver will set the relevant queue limit to
* 0 to prevent blk-lib from issuing more of the offending
* operations. Commands queued prior to the queue limit being
* reset need to be completed with BLK_STS_NOTSUPP to avoid I/O
* errors being propagated to upper layers.
*/
if (max_sectors == 0)
return BLK_STS_NOTSUPP;
printk(KERN_ERR "%s: over max size limit. (%u > %u)\n",
__func__, blk_rq_sectors(rq), max_sectors);
return BLK_STS_IOERR;
}
/*
* queue's settings related to segment counting like q->bounce_pfn
* may differ from that of other stacking queues.
* Recalculate it to check the request correctly on this queue's
* limitation.
*/
rq->nr_phys_segments = blk_recalc_rq_segments(rq);
if (rq->nr_phys_segments > queue_max_segments(q)) {
printk(KERN_ERR "%s: over max segments limit. (%hu > %hu)\n",
__func__, rq->nr_phys_segments, queue_max_segments(q));
return BLK_STS_IOERR;
}
return BLK_STS_OK;
}
/**
* blk_insert_cloned_request - Helper for stacking drivers to submit a request
* @q: the queue to submit the request
* @rq: the request being queued
*/
blk_status_t blk_insert_cloned_request(struct request_queue *q, struct request *rq)
{
blk_status_t ret;
ret = blk_cloned_rq_check_limits(q, rq);
if (ret != BLK_STS_OK)
return ret;
if (rq->rq_disk &&
should_fail_request(&rq->rq_disk->part0, blk_rq_bytes(rq)))
return BLK_STS_IOERR;
if (blk_crypto_insert_cloned_request(rq))
return BLK_STS_IOERR;
if (blk_queue_io_stat(q))
blk_account_io_start(rq);
/*
* Since we have a scheduler attached on the top device,
* bypass a potential scheduler on the bottom device for
* insert.
*/
return blk_mq_request_issue_directly(rq, true);
}
EXPORT_SYMBOL_GPL(blk_insert_cloned_request);
/**
* blk_rq_err_bytes - determine number of bytes till the next failure boundary
* @rq: request to examine
*
* Description:
* A request could be merge of IOs which require different failure
* handling. This function determines the number of bytes which
* can be failed from the beginning of the request without
* crossing into area which need to be retried further.
*
* Return:
* The number of bytes to fail.
*/
unsigned int blk_rq_err_bytes(const struct request *rq)
{
unsigned int ff = rq->cmd_flags & REQ_FAILFAST_MASK;
unsigned int bytes = 0;
struct bio *bio;
if (!(rq->rq_flags & RQF_MIXED_MERGE))
return blk_rq_bytes(rq);
/*
* Currently the only 'mixing' which can happen is between
* different fastfail types. We can safely fail portions
* which have all the failfast bits that the first one has -
* the ones which are at least as eager to fail as the first
* one.
*/
for (bio = rq->bio; bio; bio = bio->bi_next) {
if ((bio->bi_opf & ff) != ff)
break;
bytes += bio->bi_iter.bi_size;
}
/* this could lead to infinite loop */
BUG_ON(blk_rq_bytes(rq) && !bytes);
return bytes;
}
EXPORT_SYMBOL_GPL(blk_rq_err_bytes);
static void update_io_ticks(struct hd_struct *part, unsigned long now, bool end)
{
unsigned long stamp;
again:
stamp = READ_ONCE(part->stamp);
if (unlikely(stamp != now)) {
if (likely(cmpxchg(&part->stamp, stamp, now) == stamp))
__part_stat_add(part, io_ticks, end ? now - stamp : 1);
}
if (part->partno) {
part = &part_to_disk(part)->part0;
goto again;
}
}
static void blk_account_io_completion(struct request *req, unsigned int bytes)
{
if (req->part && blk_do_io_stat(req)) {
const int sgrp = op_stat_group(req_op(req));
struct hd_struct *part;
part_stat_lock();
part = req->part;
part_stat_add(part, sectors[sgrp], bytes >> 9);
part_stat_unlock();
}
}
void blk_account_io_done(struct request *req, u64 now)
{
/*
* Account IO completion. flush_rq isn't accounted as a
* normal IO on queueing nor completion. Accounting the
* containing request is enough.
*/
if (req->part && blk_do_io_stat(req) &&
!(req->rq_flags & RQF_FLUSH_SEQ)) {
const int sgrp = op_stat_group(req_op(req));
struct hd_struct *part;
part_stat_lock();
part = req->part;
update_io_ticks(part, jiffies, true);
part_stat_inc(part, ios[sgrp]);
part_stat_add(part, nsecs[sgrp], now - req->start_time_ns);
part_stat_unlock();
hd_struct_put(part);
}
}
void blk_account_io_start(struct request *rq)
{
if (!blk_do_io_stat(rq))
return;
rq->part = disk_map_sector_rcu(rq->rq_disk, blk_rq_pos(rq));
part_stat_lock();
update_io_ticks(rq->part, jiffies, false);
part_stat_unlock();
}
static unsigned long __part_start_io_acct(struct hd_struct *part,
unsigned int sectors, unsigned int op)
{
const int sgrp = op_stat_group(op);
unsigned long now = READ_ONCE(jiffies);
part_stat_lock();
update_io_ticks(part, now, false);
part_stat_inc(part, ios[sgrp]);
part_stat_add(part, sectors[sgrp], sectors);
part_stat_local_inc(part, in_flight[op_is_write(op)]);
part_stat_unlock();
return now;
}
unsigned long part_start_io_acct(struct gendisk *disk, struct hd_struct **part,
struct bio *bio)
{
*part = disk_map_sector_rcu(disk, bio->bi_iter.bi_sector);
return __part_start_io_acct(*part, bio_sectors(bio), bio_op(bio));
}
EXPORT_SYMBOL_GPL(part_start_io_acct);
unsigned long disk_start_io_acct(struct gendisk *disk, unsigned int sectors,
unsigned int op)
{
return __part_start_io_acct(&disk->part0, sectors, op);
}
EXPORT_SYMBOL(disk_start_io_acct);
static void __part_end_io_acct(struct hd_struct *part, unsigned int op,
unsigned long start_time)
{
const int sgrp = op_stat_group(op);
unsigned long now = READ_ONCE(jiffies);
unsigned long duration = now - start_time;
part_stat_lock();
update_io_ticks(part, now, true);
part_stat_add(part, nsecs[sgrp], jiffies_to_nsecs(duration));
part_stat_local_dec(part, in_flight[op_is_write(op)]);
part_stat_unlock();
}
void part_end_io_acct(struct hd_struct *part, struct bio *bio,
unsigned long start_time)
{
__part_end_io_acct(part, bio_op(bio), start_time);
hd_struct_put(part);
}
EXPORT_SYMBOL_GPL(part_end_io_acct);
void disk_end_io_acct(struct gendisk *disk, unsigned int op,
unsigned long start_time)
{
__part_end_io_acct(&disk->part0, op, start_time);
}
EXPORT_SYMBOL(disk_end_io_acct);
/*
* Steal bios from a request and add them to a bio list.
* The request must not have been partially completed before.
*/
void blk_steal_bios(struct bio_list *list, struct request *rq)
{
if (rq->bio) {
if (list->tail)
list->tail->bi_next = rq->bio;
else
list->head = rq->bio;
list->tail = rq->biotail;
rq->bio = NULL;
rq->biotail = NULL;
}
rq->__data_len = 0;
}
EXPORT_SYMBOL_GPL(blk_steal_bios);
/**
* blk_update_request - Special helper function for request stacking drivers
* @req: the request being processed
* @error: block status code
* @nr_bytes: number of bytes to complete @req
*
* Description:
* Ends I/O on a number of bytes attached to @req, but doesn't complete
* the request structure even if @req doesn't have leftover.
* If @req has leftover, sets it up for the next range of segments.
*
* This special helper function is only for request stacking drivers
* (e.g. request-based dm) so that they can handle partial completion.
* Actual device drivers should use blk_mq_end_request instead.
*
* Passing the result of blk_rq_bytes() as @nr_bytes guarantees
* %false return from this function.
*
* Note:
* The RQF_SPECIAL_PAYLOAD flag is ignored on purpose in both
* blk_rq_bytes() and in blk_update_request().
*
* Return:
* %false - this request doesn't have any more data
* %true - this request has more data
**/
bool blk_update_request(struct request *req, blk_status_t error,
unsigned int nr_bytes)
{
int total_bytes;
trace_block_rq_complete(req, blk_status_to_errno(error), nr_bytes);
if (!req->bio)
return false;
#ifdef CONFIG_BLK_DEV_INTEGRITY
if (blk_integrity_rq(req) && req_op(req) == REQ_OP_READ &&
error == BLK_STS_OK)
req->q->integrity.profile->complete_fn(req, nr_bytes);
#endif
if (unlikely(error && !blk_rq_is_passthrough(req) &&
!(req->rq_flags & RQF_QUIET)))
print_req_error(req, error, __func__);
blk_account_io_completion(req, nr_bytes);
total_bytes = 0;
while (req->bio) {
struct bio *bio = req->bio;
unsigned bio_bytes = min(bio->bi_iter.bi_size, nr_bytes);
if (bio_bytes == bio->bi_iter.bi_size)
req->bio = bio->bi_next;
/* Completion has already been traced */
bio_clear_flag(bio, BIO_TRACE_COMPLETION);
req_bio_endio(req, bio, bio_bytes, error);
total_bytes += bio_bytes;
nr_bytes -= bio_bytes;
if (!nr_bytes)
break;
}
/*
* completely done
*/
if (!req->bio) {
/*
* Reset counters so that the request stacking driver
* can find how many bytes remain in the request
* later.
*/
req->__data_len = 0;
return false;
}
req->__data_len -= total_bytes;
/* update sector only for requests with clear definition of sector */
if (!blk_rq_is_passthrough(req))
req->__sector += total_bytes >> 9;
/* mixed attributes always follow the first bio */
if (req->rq_flags & RQF_MIXED_MERGE) {
req->cmd_flags &= ~REQ_FAILFAST_MASK;
req->cmd_flags |= req->bio->bi_opf & REQ_FAILFAST_MASK;
}
if (!(req->rq_flags & RQF_SPECIAL_PAYLOAD)) {
/*
* If total number of sectors is less than the first segment
* size, something has gone terribly wrong.
*/
if (blk_rq_bytes(req) < blk_rq_cur_bytes(req)) {
blk_dump_rq_flags(req, "request botched");
req->__data_len = blk_rq_cur_bytes(req);
}
/* recalculate the number of segments */
req->nr_phys_segments = blk_recalc_rq_segments(req);
}
return true;
}
EXPORT_SYMBOL_GPL(blk_update_request);
#if ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE
/**
* rq_flush_dcache_pages - Helper function to flush all pages in a request
* @rq: the request to be flushed
*
* Description:
* Flush all pages in @rq.
*/
void rq_flush_dcache_pages(struct request *rq)
{
struct req_iterator iter;
struct bio_vec bvec;
rq_for_each_segment(bvec, rq, iter)
flush_dcache_page(bvec.bv_page);
}
EXPORT_SYMBOL_GPL(rq_flush_dcache_pages);
#endif
/**
* blk_lld_busy - Check if underlying low-level drivers of a device are busy
* @q : the queue of the device being checked
*
* Description:
* Check if underlying low-level drivers of a device are busy.
* If the drivers want to export their busy state, they must set own
* exporting function using blk_queue_lld_busy() first.
*
* Basically, this function is used only by request stacking drivers
* to stop dispatching requests to underlying devices when underlying
* devices are busy. This behavior helps more I/O merging on the queue
* of the request stacking driver and prevents I/O throughput regression
* on burst I/O load.
*
* Return:
* 0 - Not busy (The request stacking driver should dispatch request)
* 1 - Busy (The request stacking driver should stop dispatching request)
*/
int blk_lld_busy(struct request_queue *q)
{
if (queue_is_mq(q) && q->mq_ops->busy)
return q->mq_ops->busy(q);
return 0;
}
EXPORT_SYMBOL_GPL(blk_lld_busy);
/**
* blk_rq_unprep_clone - Helper function to free all bios in a cloned request
* @rq: the clone request to be cleaned up
*
* Description:
* Free all bios in @rq for a cloned request.
*/
void blk_rq_unprep_clone(struct request *rq)
{
struct bio *bio;
while ((bio = rq->bio) != NULL) {
rq->bio = bio->bi_next;
bio_put(bio);
}
}
EXPORT_SYMBOL_GPL(blk_rq_unprep_clone);
/**
* blk_rq_prep_clone - Helper function to setup clone request
* @rq: the request to be setup
* @rq_src: original request to be cloned
* @bs: bio_set that bios for clone are allocated from
* @gfp_mask: memory allocation mask for bio
* @bio_ctr: setup function to be called for each clone bio.
* Returns %0 for success, non %0 for failure.
* @data: private data to be passed to @bio_ctr
*
* Description:
* Clones bios in @rq_src to @rq, and copies attributes of @rq_src to @rq.
* Also, pages which the original bios are pointing to are not copied
* and the cloned bios just point same pages.
* So cloned bios must be completed before original bios, which means
* the caller must complete @rq before @rq_src.
*/
int blk_rq_prep_clone(struct request *rq, struct request *rq_src,
struct bio_set *bs, gfp_t gfp_mask,
int (*bio_ctr)(struct bio *, struct bio *, void *),
void *data)
{
struct bio *bio, *bio_src;
if (!bs)
bs = &fs_bio_set;
__rq_for_each_bio(bio_src, rq_src) {
bio = bio_clone_fast(bio_src, gfp_mask, bs);
if (!bio)
goto free_and_out;
if (bio_ctr && bio_ctr(bio, bio_src, data))
goto free_and_out;
if (rq->bio) {
rq->biotail->bi_next = bio;
rq->biotail = bio;
} else {
rq->bio = rq->biotail = bio;
}
bio = NULL;
}
/* Copy attributes of the original request to the clone request. */
rq->__sector = blk_rq_pos(rq_src);
rq->__data_len = blk_rq_bytes(rq_src);
if (rq_src->rq_flags & RQF_SPECIAL_PAYLOAD) {
rq->rq_flags |= RQF_SPECIAL_PAYLOAD;
rq->special_vec = rq_src->special_vec;
}
rq->nr_phys_segments = rq_src->nr_phys_segments;
rq->ioprio = rq_src->ioprio;
if (rq->bio && blk_crypto_rq_bio_prep(rq, rq->bio, gfp_mask) < 0)
goto free_and_out;
return 0;
free_and_out:
if (bio)
bio_put(bio);
blk_rq_unprep_clone(rq);
return -ENOMEM;
}
EXPORT_SYMBOL_GPL(blk_rq_prep_clone);
int kblockd_schedule_work(struct work_struct *work)
{
return queue_work(kblockd_workqueue, work);
}
EXPORT_SYMBOL(kblockd_schedule_work);
int kblockd_mod_delayed_work_on(int cpu, struct delayed_work *dwork,
unsigned long delay)
{
return mod_delayed_work_on(cpu, kblockd_workqueue, dwork, delay);
}
EXPORT_SYMBOL(kblockd_mod_delayed_work_on);
/**
* blk_start_plug - initialize blk_plug and track it inside the task_struct
* @plug: The &struct blk_plug that needs to be initialized
*
* Description:
* blk_start_plug() indicates to the block layer an intent by the caller
* to submit multiple I/O requests in a batch. The block layer may use
* this hint to defer submitting I/Os from the caller until blk_finish_plug()
* is called. However, the block layer may choose to submit requests
* before a call to blk_finish_plug() if the number of queued I/Os
* exceeds %BLK_MAX_REQUEST_COUNT, or if the size of the I/O is larger than
* %BLK_PLUG_FLUSH_SIZE. The queued I/Os may also be submitted early if
* the task schedules (see below).
*
* Tracking blk_plug inside the task_struct will help with auto-flushing the
* pending I/O should the task end up blocking between blk_start_plug() and
* blk_finish_plug(). This is important from a performance perspective, but
* also ensures that we don't deadlock. For instance, if the task is blocking
* for a memory allocation, memory reclaim could end up wanting to free a
* page belonging to that request that is currently residing in our private
* plug. By flushing the pending I/O when the process goes to sleep, we avoid
* this kind of deadlock.
*/
void blk_start_plug(struct blk_plug *plug)
{
struct task_struct *tsk = current;
/*
* If this is a nested plug, don't actually assign it.
*/
if (tsk->plug)
return;
INIT_LIST_HEAD(&plug->mq_list);
INIT_LIST_HEAD(&plug->cb_list);
plug->rq_count = 0;
plug->multiple_queues = false;
plug->nowait = false;
/*
* Store ordering should not be needed here, since a potential
* preempt will imply a full memory barrier
*/
tsk->plug = plug;
}
EXPORT_SYMBOL(blk_start_plug);
static void flush_plug_callbacks(struct blk_plug *plug, bool from_schedule)
{
LIST_HEAD(callbacks);
while (!list_empty(&plug->cb_list)) {
list_splice_init(&plug->cb_list, &callbacks);
while (!list_empty(&callbacks)) {
struct blk_plug_cb *cb = list_first_entry(&callbacks,
struct blk_plug_cb,
list);
list_del(&cb->list);
cb->callback(cb, from_schedule);
}
}
}
struct blk_plug_cb *blk_check_plugged(blk_plug_cb_fn unplug, void *data,
int size)
{
struct blk_plug *plug = current->plug;
struct blk_plug_cb *cb;
if (!plug)
return NULL;
list_for_each_entry(cb, &plug->cb_list, list)
if (cb->callback == unplug && cb->data == data)
return cb;
/* Not currently on the callback list */
BUG_ON(size < sizeof(*cb));
cb = kzalloc(size, GFP_ATOMIC);
if (cb) {
cb->data = data;
cb->callback = unplug;
list_add(&cb->list, &plug->cb_list);
}
return cb;
}
EXPORT_SYMBOL(blk_check_plugged);
void blk_flush_plug_list(struct blk_plug *plug, bool from_schedule)
{
flush_plug_callbacks(plug, from_schedule);
if (!list_empty(&plug->mq_list))
blk_mq_flush_plug_list(plug, from_schedule);
}
/**
* blk_finish_plug - mark the end of a batch of submitted I/O
* @plug: The &struct blk_plug passed to blk_start_plug()
*
* Description:
* Indicate that a batch of I/O submissions is complete. This function
* must be paired with an initial call to blk_start_plug(). The intent
* is to allow the block layer to optimize I/O submission. See the
* documentation for blk_start_plug() for more information.
*/
void blk_finish_plug(struct blk_plug *plug)
{
if (plug != current->plug)
return;
blk_flush_plug_list(plug, false);
current->plug = NULL;
}
EXPORT_SYMBOL(blk_finish_plug);
void blk_io_schedule(void)
{
/* Prevent hang_check timer from firing at us during very long I/O */
unsigned long timeout = sysctl_hung_task_timeout_secs * HZ / 2;
if (timeout)
io_schedule_timeout(timeout);
else
io_schedule();
}
EXPORT_SYMBOL_GPL(blk_io_schedule);
int __init blk_dev_init(void)
{
BUILD_BUG_ON(REQ_OP_LAST >= (1 << REQ_OP_BITS));
BUILD_BUG_ON(REQ_OP_BITS + REQ_FLAG_BITS > 8 *
sizeof_field(struct request, cmd_flags));
BUILD_BUG_ON(REQ_OP_BITS + REQ_FLAG_BITS > 8 *
sizeof_field(struct bio, bi_opf));
/* used for unplugging and affects IO latency/throughput - HIGHPRI */
kblockd_workqueue = alloc_workqueue("kblockd",
WQ_MEM_RECLAIM | WQ_HIGHPRI, 0);
if (!kblockd_workqueue)
panic("Failed to create kblockd\n");
blk_requestq_cachep = kmem_cache_create("request_queue",
sizeof(struct request_queue), 0, SLAB_PANIC, NULL);
blk_debugfs_root = debugfs_create_dir("block", NULL);
return 0;
}
|
__label__pos
| 0.988459 |
Terabyte of Click Logs from Criteo
Download the data from http://labs.criteo.com/downloads/download-terabyte-click-logs/
Create a table to import the log to:
CREATE TABLE criteo_log (date Date, clicked UInt8, int1 Int32, int2 Int32, int3 Int32, int4 Int32, int5 Int32, int6 Int32, int7 Int32, int8 Int32, int9 Int32, int10 Int32, int11 Int32, int12 Int32, int13 Int32, cat1 String, cat2 String, cat3 String, cat4 String, cat5 String, cat6 String, cat7 String, cat8 String, cat9 String, cat10 String, cat11 String, cat12 String, cat13 String, cat14 String, cat15 String, cat16 String, cat17 String, cat18 String, cat19 String, cat20 String, cat21 String, cat22 String, cat23 String, cat24 String, cat25 String, cat26 String) ENGINE = Log
Download the data:
for i in {00..23}; do echo $i; zcat datasets/criteo/day_${i#0}.gz | sed -r 's/^/2000-01-'${i/00/24}'\t/' | clickhouse-client --host=example-perftest01j --query="INSERT INTO criteo_log FORMAT TabSeparated"; done
Create a table for the converted data:
CREATE TABLE criteo
(
date Date,
clicked UInt8,
int1 Int32,
int2 Int32,
int3 Int32,
int4 Int32,
int5 Int32,
int6 Int32,
int7 Int32,
int8 Int32,
int9 Int32,
int10 Int32,
int11 Int32,
int12 Int32,
int13 Int32,
icat1 UInt32,
icat2 UInt32,
icat3 UInt32,
icat4 UInt32,
icat5 UInt32,
icat6 UInt32,
icat7 UInt32,
icat8 UInt32,
icat9 UInt32,
icat10 UInt32,
icat11 UInt32,
icat12 UInt32,
icat13 UInt32,
icat14 UInt32,
icat15 UInt32,
icat16 UInt32,
icat17 UInt32,
icat18 UInt32,
icat19 UInt32,
icat20 UInt32,
icat21 UInt32,
icat22 UInt32,
icat23 UInt32,
icat24 UInt32,
icat25 UInt32,
icat26 UInt32
) ENGINE = MergeTree(date, intHash32(icat1), (date, intHash32(icat1)), 8192)
Transform data from the raw log and put it in the second table:
INSERT INTO criteo SELECT date, clicked, int1, int2, int3, int4, int5, int6, int7, int8, int9, int10, int11, int12, int13, reinterpretAsUInt32(unhex(cat1)) AS icat1, reinterpretAsUInt32(unhex(cat2)) AS icat2, reinterpretAsUInt32(unhex(cat3)) AS icat3, reinterpretAsUInt32(unhex(cat4)) AS icat4, reinterpretAsUInt32(unhex(cat5)) AS icat5, reinterpretAsUInt32(unhex(cat6)) AS icat6, reinterpretAsUInt32(unhex(cat7)) AS icat7, reinterpretAsUInt32(unhex(cat8)) AS icat8, reinterpretAsUInt32(unhex(cat9)) AS icat9, reinterpretAsUInt32(unhex(cat10)) AS icat10, reinterpretAsUInt32(unhex(cat11)) AS icat11, reinterpretAsUInt32(unhex(cat12)) AS icat12, reinterpretAsUInt32(unhex(cat13)) AS icat13, reinterpretAsUInt32(unhex(cat14)) AS icat14, reinterpretAsUInt32(unhex(cat15)) AS icat15, reinterpretAsUInt32(unhex(cat16)) AS icat16, reinterpretAsUInt32(unhex(cat17)) AS icat17, reinterpretAsUInt32(unhex(cat18)) AS icat18, reinterpretAsUInt32(unhex(cat19)) AS icat19, reinterpretAsUInt32(unhex(cat20)) AS icat20, reinterpretAsUInt32(unhex(cat21)) AS icat21, reinterpretAsUInt32(unhex(cat22)) AS icat22, reinterpretAsUInt32(unhex(cat23)) AS icat23, reinterpretAsUInt32(unhex(cat24)) AS icat24, reinterpretAsUInt32(unhex(cat25)) AS icat25, reinterpretAsUInt32(unhex(cat26)) AS icat26 FROM criteo_log;
DROP TABLE criteo_log;
|
__label__pos
| 0.781093 |
What advances are being made in energy-efficient computing?
Energy-efficient computing is a growing trend in the technology world. It involves the use of computing devices and systems that consume less electricity, thus reducing the environmental footprint and operating costs. The rise of digital technology is driving the need for more power to sustain the growing data needs of individuals, corporations, and governments. However, there is a growing concern about the impact of this consumption on the environment and the need for more efficient devices and systems. In this article, we will explore some of the advances being made in energy-efficient computing and how they are shaping the future of the industry.
Harnessing Green Energy in Computing Infrastructure
Green energy has become a popular buzzword in the world of computing. It refers to the use of renewable energy sources such as wind, solar, and hydroelectric energy, as a power source for computing infrastructure. As more digital technologies emerge, the demand for electricity in the computing industry continues to rise. Harnessing green energy in computing infrastructure is an innovation geared towards reducing this consumption and promoting sustainability.
Avez-vous vu cela : Can Virtual Reality Therapy Offer New Solutions for Anxiety and PTSD?
Renewable energy technologies have become more efficient and reliable over the years, making them a viable option for powering data centers and other computing infrastructure. Companies such as Google and Apple have made significant strides in this area, with some of their data centers running entirely on renewable energy. This shift to green energy not only reduces the carbon footprint of these companies but also results in significant cost savings.
Improvements in Processor Performance and Efficiency
One of the major areas where advances are being made in energy-efficient computing is the design and engineering of processors. Processors are the heart of any computing device, and their performance and efficiency greatly impact the overall energy consumption of the device.
Dans le meme genre : What are the advantages of using a chatbot for human resources ?
Companies like Intel and AMD have been working tirelessly to increase the performance of their processors while reducing their power consumption. These companies are employing new engineering techniques and technologies to achieve this goal. For example, they are developing processors with more cores, which allows for greater parallel processing and hence, improves performance. They are also designing processors that can dynamically adjust their power consumption based on the workload, thereby increasing efficiency.
The Rise of Energy-Efficient Data Storage
As the volume of digital data continues to increase exponentially, so does the need for efficient data storage systems. Traditional hard drives and solid-state drives consume a significant amount of electricity, especially in large data centers. This has led to the development of more energy-efficient data storage technologies.
One such technology is the helium-filled hard drive, which consumes less power and runs cooler than traditional hard drives. Other advances include the use of new materials in the manufacture of solid-state drives, which reduces their energy consumption.
Energy Consumption Optimization in Software
Energy consumption in computing is not only determined by the hardware but also by the software running on the device. Therefore, software developers are now taking energy consumption into consideration when developing their software.
This involves optimizing the software to make better use of the available hardware resources and therefore, reduce the amount of electricity consumed. For example, developers can optimize their software to take advantage of multi-core processors, thus reducing the amount of power consumed. They can also design their software to enter a low-power mode when not in use, thereby saving energy.
The Role of AI and Machine Learning in Energy-Efficient Computing
Artificial Intelligence (AI) and Machine Learning (ML) technologies are playing a significant role in advancing energy-efficient computing. These technologies can be used to analyze and predict the energy consumption patterns of a computing system, thus enabling the system to adapt its power consumption dynamically.
For instance, AI and ML can be used to optimize the performance of a data center by predicting the workload and adjusting the power consumption accordingly. They can also be used to manage the cooling systems in the data center, which is a major contributor to power consumption.
Energy-efficient computing is a rapidly evolving field with a lot of potential for innovation and growth. As the demand for digital technology continues to rise, so does the need for more efficient computing systems. The advances being made in this field are not only beneficial to the environment, but they also result in significant cost savings, making them a win-win for everyone involved.
Quantum Computing: The Future of Energy Efficiency
Quantum computing presents a promising future for the energy sector. Quantum computers operate on quantum bits or qubits, which can exist in multiple states at once. This capability allows them to perform complex calculations much faster than traditional computers. Simultaneously, quantum computers are potentially more energy-efficient, making them an exciting development in the push for more sustainable digital technologies.
Quantum computers can perform many operations simultaneously, reducing the number of calculations needed, hence reducing energy consumption. Researchers have also noted that quantum computers generate less heat, minimizing cooling requirements, which often account for a large portion of a data center’s energy use.
IBM, Google, and Microsoft are leading the race in developing scalable quantum computers. They are investing heavily in researching their energy efficiency potential, with the hope of revolutionizing the computing industry by significantly reducing the energy consumption of high-performance computing systems.
Despite the promise of quantum computing, it’s still in its early stages. Many technical challenges need to be overcome to make them commercially viable. However, the potential for substantial energy savings and improved performance makes quantum computing a key area for future development in the energy-efficient computing field.
The Potential of Cloud Computing for Energy Efficiency
Cloud computing is another area where significant strides are being made in energy efficiency. Cloud computing involves storing and processing data on remote servers instead of local servers or personal computers. This shift has the potential to dramatically reduce energy consumption in the digital sector.
Cloud service providers such as Amazon Web Services, Google Cloud, and Microsoft Azure are continually optimizing their data centers for energy efficiency. Their scale allows for more effective power management and cooling systems, resulting in less energy waste. Moreover, they are increasingly powered by clean energy sources, further reducing their carbon footprint.
By moving to the cloud, businesses can leverage these energy efficiencies. Instead of maintaining their own energy-hungry data centers, they can outsource their data storage and computing needs to these more efficient cloud-based systems.
In addition to the direct energy savings, cloud computing also promotes more efficient hardware utilization. Since hardware resources are shared among multiple users, there is less need for each user to have their own high-performance, energy-consuming devices.
Conclusion
The advancements in energy-efficient computing are essential for the sustainability of our digital future. As the demand for data and digital services continues to rise, so must our commitment to reducing the energy consumption and environmental impact of these services.
Harnessing renewable energy sources, developing more efficient hardware and software, leveraging AI and machine learning, and exploring the potential of emerging technologies like quantum and cloud computing, are all crucial steps towards achieving this goal.
The benefits of energy-efficient computing go beyond just energy savings and a reduced carbon footprint. They also include significant cost savings and improved performance, making them a win-win solution for the environment and businesses alike.
As we progress further into the digital age, it’s clear that energy-efficient computing will play a pivotal role in shaping our digital landscape. Its advancements will not only drive sustainability in the digital sector but also influence broader shifts towards more sustainable and efficient practices across all sectors.
|
__label__pos
| 0.998067 |
How to use AI in ecommerce SEO strategy
How To Use AI In Ecommerce SEO Strategy
In Content9 May 202313 Minutes
Even if you’ve lived under a rock for the past few years, you’ll be aware of the leaps and bounds that AI (artificial intelligence) technology has made. AI is working its way into a variety of different sectors, including ecommerce. Ecommerce businesses might use AI for a customer chat service, to recommend products to potential customers, or simply to understand their customers better.
However, implementing AI as part of a fully formed SEO content strategy can be the extra edge you need to get ahead of your competitors. Particularly when used for category or product page content, using a good AI tool will ensure that you are making the most out of every page possible.
How is AI used in SEO?
When it comes to SEO, AI can be used in a variety of different ways – however, our favourite, and the way we believe creates the most effective results, is by using an AI service to create content. This can be a tricky business to navigate; sometimes, AI-generated copy may not fulfil the intent or be of the quality that search engines like Google expect. However, providing you use a good AI content writing software, and add enough of a human touch to ensure that it reads well and fulfils the required purpose, utilising AI in your ecommerce SEO strategy can help to give you a boost in the SERPs that will have a real impact on your performance.
Using AI for product pages
Predominantly, the biggest impact you can make to your site is by employing AI for product page content. Particularly for businesses that stock a wide variety of different products, creating individual product descriptions that effectively and accurately describe the product whilst also providing SEO value can be a cumbersome task.
Employing a good AI tool can enable you to produce product copy en masse, saving you some time and effort but still turning out quality results. One of the biggest benefits of using AI for product descriptions is the ability to generate unique and high-quality content for each and every product on your site, helping to ensure that your product pages are as informative and engaging as possible, which in turn can help to improve their search engine rankings. AI-generated product descriptions can also include important keywords and phrases that are relevant to each product, which can help to boost their visibility in search results.
If, for example, you have a variety of different domains for the same products, you will require different copy for each to avoid plagiarism – and AI can also be used to rewrite product descriptions and content to provide you with something fresh that serves the same purpose.
You can also train AI chatbots, such as ChatGPT, to produce the content that you need. Feeding it very detailed prompts and being as specific as you can be about what you need from the output will ensure the best copy possible.
Benefits of AI for product page content
1. AI can help to automate the process of creating product descriptions, saving you time and resources. This can free up your team to focus on other important aspects of your SEO strategy, such as link building and keyword research.
2. AI-generated product descriptions can sometimes be more accurate and relevant than those written by humans. AI algorithms can analyse the data about products and use it to create descriptions that are tailored to the specific characteristics of each product.
3. AI-generated product descriptions can include important keywords and phrases that are relevant to each product, which can help to boost their visibility in search results. AI algorithms can analyse product data and identify the most important keywords and phrases to include in the descriptions, which can help to optimise your product pages for SEO.
4. AI-generated product descriptions can help to improve the overall user experience on your website. By providing accurate and relevant information about products, AI-generated content can make it easier for shoppers to find what they are looking for, and can help to reduce bounce rates and increase conversion rates.
Using AI for category pages
When it comes to ecommerce sites, there may be thousands of different category pages, each with an almost-infinite combination of different filters that can be applied. Take a site that sells washing machines, for example: they may have a category for free standing washing machines, that can then be filtered by brand, size, price and so on. When it comes down to it, that Free Standing category has been turned into a more specific page containing products matching: [Type: Free Standing] [Brand: (brand)] [Capacity: 1kg] [Price: Under £500]. The list could go on.
Creating copy for these pages would be long and arduous – however, plenty of AI writing software can allow you to import the data you have on these pages, running an automated process to create tailored copy for each of these. So, sub-category pages that may have been neglected simply due to a shortage of time and resources can be given new life, with SEO-focussed copy created that will help them perform well, like their parent categories, in the SERPs.
Benefits of AI for category page content
1. Instead of manually writing descriptions for each category page on your website, you can use AI to generate them quickly and efficiently. Like product pages, categories can be vast and creating top and bottom copy for each one can feel like a slog.
2. AI-generated content will target for the ideal keywords for your category page. This can help to ensure that your category pages are as informative and engaging as possible, which in turn can help to improve their search engine rankings.
3. Category page content is often bolstered by the inclusion of FAQs, which AI copywriters can generate and answer. This will signal to search engines like Google that your site is trustworthy, and in turn, your products are worth promoting.
4. AI-generated copy can also be an easy way of keeping your category pages up-to-date. Like in the example given above, there can be a wide variety of different filters that will create new category pages, and with each new filter added, there will be new pages created that require unique copy.
Why use AI for your ecommerce SEO strategy?
Overall, using AI for product descriptions and category content in ecommerce can be a valuable tool for improving your SEO strategy. By automating the process of creating product descriptions, ensuring their accuracy, relevance, and including important keywords, you can improve the visibility of your products and enhance the user experience on your website.
Best AI tools for ecommerce sites
When it comes to using AI to produce product and category content, it’s important to find a reliable, good quality tool that will write content that requires minimal edits.
OpenAI’s ChatGPT
This is currently a free service, which utilises a chatbot service to produce content. By providing a prompt, you can ask the chat for anything – product descriptions, category copy, even full blog posts – and it will respond with the content you need.
Say for example you sell blue sofa cushions in a variety of different textures and materials. Simply ask ChatGPT to produce category content on blue sofa cushions, add some information on the textures and materials and ask for top and bottom copy, with some FAQs, and it will oblige.
Frase
This is another free AI copywriting tool, which has a specific product description generator. This will require you to have keywords already discovered for the product, but simply input the product title, the keywords and change the ‘creativity’ toggle to how creative you’d like the copy to be, and generate.
Copysmith AI
This is a service that is useful when producing a vast array of product descriptions. Whether you need to create a variety of descriptions, or if you are planning on adding your products to a new site to boost sales and need to rewrite the descriptions you already have, you can upload the product descriptions you require with related keywords and generate them in bulk.
Are there any risks associated with AI copy generation?
When using AI for copy generation, it’s important to be aware that it will always need a human touch. Whilst many AI tools create comprehensive copy that is almost site-ready, be sure to cast your eye over it and make the edits required to ensure it doesn’t sound like something written by a robot.
Additionally, Google has become increasingly aware of AI-written copy, and their algorithms can detect copy that has been produced entirely with artificial intelligence. Therefore, it’s more important than ever to ensure that you are manually making edits to the copy produced to allow the page to be served well by Google and appear in the rankings. As a result of this, many AI copy checkers (such as this one from Copy Leaks, that keeps up to date with each version of ChatAI in particular) that can tell you how your content reads, and how heavily you will need to edit it before adding it to your site.
Ecommerce SEO with Custard
We offer bespoke ecommerce SEO strategies, using years’ worth of expertise as an ecommerce SEO agency to produce content strategies that will make a difference to your site’s organic performance. If you’ve found that you require services relating to product and category content for your site and you’re unsure whether you have the capacity to manage it, contact us today to discover how our content team can help you.
|
__label__pos
| 0.673641 |
Internal database schema
The following tables are used internally by DeepDive. There can not be tables with the same name in the database:
List of relations
Schema | Name | Type
--------+----------------------------------------------+----------
public | dd_graph_variables_holdout | table
public | dd_graph_variables_observation | table
public | dd_graph_weights | table
public | dd_inference_result_variables | table
public | dd_inference_result_weights | table
public | dd_inference_result_weights_mapping | view
public | dd_factors_[RULE_NAME] | table
public | dd_weights_[RULE_NAME] | table
public | [TABLE]_[VARIABLE]_inference | view
public | [TABLE]_[VARIABLE]_calibration | view
public | dd_categories_[TABLE] | view
where [RULE_NAME] is the name of an inference rule, [TABLE] is the name of a table that contains variables, and [VARIABLE] is the name of a variable in the corresponding table.
Description of each schema:
• dd_graph_variables_holdout: a table that contains all variable ids that are used for holdout. Can be used for custom holdout by a holdout query.
• dd_graph_variables_observation: a table that contains all variable ids that are evidence that will not be fitted during learning. An usage example of this table can be found here.
• dd_graph_weights: a table that contains all the materialized weights.
• dd_inference_result_variables: a table that contains the inference results (expectation) for all query variables.
• dd_inference_result_weights: a table that shows factor weight ids and learned weight values.
• dd_inference_result_weights_mapping: a view that maps all distinct factor weights to their description and their learned values. It is a commonly used view that shows the learned weight value of a factor as well as the number of occurences of a factor.
• dd_factors_[RULE_NAME]: a table that is defined by the input query of an inference rule. You can use it as a feature table in BrainDump.
• dd_weight_[RULE_NAME]: a table that stores initial weights for factors, used internally.
• [TABLE]_[VARIABLE]_inference: a view that maps variables with their inference results. It is commonly used for error analysis.
• [TABLE]_[VARIABLE]_calibration: a view that has calibration statistics of a variable. Used in generating calibration plots.
• dd_categories_[TABLE]: a view that records the cardinality series of given variable. For example if the domain of a variable is {1,2,3} the cardinality is 3.
|
__label__pos
| 0.844068 |
Go package for automation of Junos (Juniper Networks) devices.
Go
Switch branches/tags
Nothing to show
Clone or download
README.md
go-junos
GoDoc Travis-CI Go Report Card
A Go package that interacts with Junos devices, as well as Junos Space, and allows you to do the following:
• Run operational mode commands, such as show, request, etc..
• Compare the active configuration to a rollback configuration (diff).
• Rollback the configuration to a given state or a "rescue" config.
• Configure devices by submitting commands, uploading a local file or from a remote FTP/HTTP server.
• Commit operations: lock, unlock, commit, commit at, commit confirmed, commit full.
• Device views - This will allow you to quickly get all the information on the device for the specified view.
• [SRX] Convert from a zone-based address book to a global one.
Junos Space <= 15.2
• Get information from Junos Space managed devices.
• Add/remove devices from Junos Space.
• List all software image packages that are in Junos Space.
• Stage and deploy software images to devices from Junos Space.
• Create, edit and delete address and service objects/groups.
• Edit address and service groups by adding or removing objects to them.
• View all policies managed by Junos Space.
• Publish policies and update devices.
• Add/modify polymorphic (variable) objects.
Installation
go get -u github.com/scottdware/go-junos
Note: This package makes all of it's calls over Netconf using the go-netconf package from Juniper Networks. Please make sure you allow Netconf communication to your devices:
set system services netconf ssh
set security zones security-zone <xxx> interfaces <xxx> host-inbound-traffic system-services netconf
Authentication Methods
There are two different ways you can authenticate against to device. Standard username/password combination, or use SSH keys. There is an AuthMethod struct which defines these methods that you will need to use in your code. Here is an example of connecting to a device using only a username and password.
auth := &junos.AuthMethod{
Credentials: []string{"scott", "deathstar"},
}
jnpr, err := junos.NewSession("srx.company.com", auth)
if err != nil {
fmt.Println(err)
}
If you are using SSH keys, here is an example of how to connect:
auth := &junos.AuthMethod{
Username: "scott",
PrivateKey: "/home/scott/.ssh/id_rsa",
Passphrase: "mysecret",
}
jnpr, err := junos.NewSession("srx.company.com", auth)
if err != nil {
fmt.Println(err)
}
If you do not have a passphrase tied to your private key, then you can omit the Passphrase field entirely. In the above example, we are connecting from a *nix/Mac device, as shown by the private key path. No matter the OS, as long as you provide the location of the private key file, you should be fine.
If you are running Windows, and using PuTTY for all your SSH needs, then you will need to generate a public/private key pair by using Puttygen. Once you have generated it, you will need to export your private key using the OpenSSH format, and save it somewhere as shown below:
alt-text
Examples
Visit the GoDoc page for package documentation and examples.
Connect to a device, and view the current config to rollback 1.
auth := &junos.AuthMethod{
Credentials: []string{"admin", "Juniper123!"},
}
jnpr, err := junos.NewSession("qfx-switch.company.com", auth)
if err != nil {
fmt.Println(err)
}
defer jnpr.Close()
diff, err := jnpr.Diff(1)
if err != nil {
fmt.Println(err)
}
fmt.Println(diff)
// Will output the following
[edit vlans]
- zzz-Test {
- vlan-id 999;
- }
- zzz-Test2 {
- vlan-id 1000;
- }
View the routing-instance configuration.
auth := &junos.AuthMethod{
Username: "admin",
PrivateKey: "/home/scott/.ssh/id_rsa",
}
jnpr, err := junos.NewSession("srx.company.com", auth)
if err != nil {
fmt.Println(err)
}
defer jnpr.Close()
riConfig, err := jnpr.GetConfig("text", "routing-instances")
if err != nil {
fmt.Println(err)
}
fmt.Println(riConfig)
// Will output the following
## Last changed: 2017-03-24 12:26:58 EDT
routing-instances {
default-ri {
instance-type virtual-router;
interface lo0.0;
interface reth1.0;
routing-options {
static {
route 0.0.0.0/0 next-hop 10.1.1.1;
}
}
}
}
Views
Device views allow you to quickly gather information regarding a specific "view," so that you may use that information however you wish. A good example, is using the "interface" view to gather all of the interface information on the device, then iterate over that view to see statistics, interface settings, etc.
Note: Some of the views aren't available for all platforms, such as the ethernetswitch and virtualchassis on an SRX or MX.
Current out-of-the-box, built-in views are:
Views CLI equivilent
arp show arp
route show route
bgp show bgp summary
interface show interfaces
vlan show vlans
ethernetswitch show ethernet-switching table
inventory show chassis hardware
virtualchassis show virtual-chassis status
staticnat show security nat static rule all
sourcenat show security nat source rule all
storage show system storage
firewallpolicy show security policies (SRX only)
NOTE: Clustered SRX's will only show the NAT rules from one of the nodes, since they are duplicated on the other.
You can even create your own views by creating a struct that models the XML output from using the GetConfig() function. Granted, this is a little more work, and requires you to know a bit more about the Go language (such as unmarshalling XML), but if there's a custom view that you want to see, it's possible to do this for anything you want.
I will be adding more views over time, but feel free to request ones you'd like to see by emailing me, or drop me a line on Twitter.
Example: View the ARP table on a device
views, err := jnpr.Views("arp")
if err != nil {
fmt.Println(err)
}
fmt.Printf("# ARP entries: %d\n\n", views.Arp.Count)
for _, a := range views.Arp.Entries {
fmt.Printf("MAC: %s\n", a.MACAddress)
fmt.Printf("IP: %s\n", a.IPAddress)
fmt.Printf("Interface: %s\n\n", a.Interface)
}
// Will print out the following
# ARP entries: 4
MAC: 00:01:ab:cd:4d:73
IP: 10.1.1.28
Interface: reth0.1
MAC: 00:01:ab:cd:0a:93
IP: 10.1.1.30
Interface: reth0.1
MAC: 00:01:ab:cd:4f:8c
IP: 10.1.1.33
Interface: reth0.1
MAC: 00:01:ab:cd:f8:30
IP: 10.1.1.36
Interface: reth0.1
|
__label__pos
| 0.529555 |
Disk Arrays
cancel
Showing results for
Search instead for
Did you mean:
Very High Write Latencies in EVAperf? Indicative of What?
Alzhy
Honored Contributor
Very High Write Latencies in EVAperf? Indicative of What?
And slow to occasional hiccups on a somewhat huge vMware ESX (14 ESX 3.02 Proliant DL580s) + a sprinkling of HP-UX.
Latencies (Wtite) reaching/bursting over 1000ms even 5000+ ms.! And FP Queue Depths of more than 20 to over 100!
Could this be indicative of our VRAID layouts? All are vRAID5 (Mix of FATA and FC).
Any inputs will be appreicated.
EVA8000, XCS 6100.
2Gbit FrontEnds x 8.
Hakuna Matata.
10 REPLIES
Tom O'Toole
Respected Contributor
Re: Very High Write Latencies in EVAperf? Indicative of What?
What do mirror port usages look like?
Can you imagine if we used PCs to manage our enterprise systems? ... oops.
Alzhy
Honored Contributor
Re: Very High Write Latencies in EVAperf? Indicative of What?
How do I Check man?
Hakuna Matata.
Jonathan Harris_3
Trusted Contributor
Re: Very High Write Latencies in EVAperf? Indicative of What?
Mirror port throughput can be measured through evaperf vdg
Generally, there should be a low correlation between write throughput and mirror port throughput. If it's high, that would indicate badly aligned or random VRAID5 writes.
Generally, this is more an issue for the older EVA GLs (3000s and 5000s) than the EVA XLs (4/6/8000). Because the EVA GLs operated active / passive, any I/O for a vdisk that arrives on the controller not controlling the destination vdisk has to pass across the mirror port. With active / active this is less of an issue, but it's still worth looking at.
Anyway, let's chuck a few other things in to the mix...
What are you using your FATA disks for? FATA is fine for sequential I/O in non-critical areas. Use it for random I/O and you'll find that stuff will grind to a halt. I'm also assuming that you're not mixing and matching in your DGs.
What's the general throughput on the FPs like during periods of poor performance?
Have you compared throughput on your switch ports to try and correlate periods of poor performance with high bandwidth utilisation from one or more servers? Do the hic-cups occur at a time when somebody's running an intensive batch job?
Are you running CA? If so, what sort of bandwidth have you got to the partner?
How is the EVA carved up? How many disk groups? How many disks per group? Which vdisks are in which group?
What applications are running (eg, databases, file and print, etc)? How are these distributed between disks and disk groups? How many virtual machines are running on the ESX?
The figures you're touting are really bad for an 8000. Unfortunately, diagnosing poor performance on an EVA can be incredibly difficult, not least because HP are convinced that you don't need to monitor performance in an EVA (it's all supposed to take care of itself). However, hopefully, we can start narrowing down the possibilities and point you at the source of your problem.
Uwe Zessin
Honored Contributor
Re: Very High Write Latencies in EVAperf? Indicative of What?
> Because the EVA GLs operated active / passive, any I/O for a vdisk that arrives on the controller not controlling the destination vdisk has to pass across the mirror port.
That is not what I have been taught: a read or write I/O to a SCSI LUN on a non-owning controller is rejected.
> With active / active this is less of an issue, but it's still worth looking at.
It can be an issue for the GLs with A/A firmware, because they have only one mirror port. So read I/Os through non-optimized paths go over this port as well as all write I/O (either non-owned or cache mirror traffic).
.
Alzhy
Honored Contributor
Re: Very High Write Latencies in EVAperf? Indicative of What?
We are still experiencing these unbelievable performance out of our EVA8000 and our vMware environments.
The Diskgroup where the vMware VRAI5 luns are carved from are about 96x300GB 10K rpm FC Disks.
The hiccups and vMware "pauses" (3-10 seconds) coincide with the EVA8000 stats showing these host port latencies which sometimes approach up to 13000 ms!
When we first moved the vMware environments to this EVA, there was some bit of a miscongiguration on the vMware side as well as onm the EVA host mode side. The vMware side was set to MRU indtead of FIXED (with distibution of the paths). On the EVA side, the host mode was "custom" (for A/P carried over from an EVA5K) instead of "vMware". Those misconfigurations have already been fixed BUT these hiccups/pauses on the vMware Guests (all Windows XP Professional) linger on with the EVa8K stats still continuing to show latencies whenever these hiccups/pauses occur.
EVA Controller Stats never exceed 25% for both data and cpu. The UNIX "CLients of these EVA" seem to be unaffected. The UNIX clients use the same diskgroup as the vMware as well as another FATA DG.
We're taken a few stats on the ESX hosts and indeed the vMware LUNS show latencies as well. Q Depth settings on the ESX host is set at 64. The typical vmware ESX LUN is sized 300GB each with 10-15 vMware Guests.
Any other ideas?
Currently I am testing one Virtual Machine to be hosted on a VRAID1 LUN ...
Hakuna Matata.
Alzhy
Honored Contributor
Re: Very High Write Latencies in EVAperf? Indicative of What?
Update:
My performance is significvantly better on this vRAID1 LUN. There still appears to be hiccups and pauses and the FP latencies still show..
I also started gathering LUN Level stats via "evaperf vd -fvd". All the VRAID5 LUNS have consistent write latencies ranging from 1 to 23 seconds! Whilst our lone VRAID1 LUN also had latencies in seconds but to a lesser recurrence..
Do you think now the issue is possibly with the XCS 6100 firmware on this EVA 8000?
We are about to engage vMware and HP...
Hakuna Matata.
Amar_Joshi
Honored Contributor
Re: Very High Write Latencies in EVAperf? Indicative of What?
I strongly believe that data layout on VDisk is not optimized or disks are heavily used for random IOs. High number in QueueDepth and high write latency is a great combination to conclude this. But, you may wanna see and match the write latency from the Host versus write latency on the EVA, if you see the same numbers it's EVA cache which is not performing because host should have low write latency due to its writing onto the cache.
Great idea would be to check and compare random-read, random-write, sequential-read & sequential-write IOPS from individual host. If your random numbers are high, you may want to redesign the VDisk layout, such as create a separate DiskGroup and then check the performance.
My 2 cents worth...
Theta Wizard
Occasional Visitor
Re: Very High Write Latencies in EVAperf? Indicative of What?
Did you ever resolve the 3-10 second pause issue using VMWare? Currently experiencing the same issue on our network.
Jeff Lawrence
Regular Advisor
Re: Very High Write Latencies in EVAperf? Indicative of What?
FYI - i had this issue with vpshere and an EVA with read/write latency spikes and found that I had a slow GBIC in one of my EVA controller ports - changed that out to the appropriate speed GBIC and the spikes went away. I had a 2GB GBIC and replaced it with a 4GB GBIC
Kurt Gunter
Advisor
Re: Very High Write Latencies in EVAperf? Indicative of What?
I've also had this issue due to failing disks which were not yet marked as bad by the EVA. Check the EVA logs for mentions of disks with errors. Open the text file "details" and search for "Enc" and "Bay" which will tell you which enclosure and bay the potentially bad disk occupies. Ungroup this disk (or disks) and see if you get improvement.
|
__label__pos
| 0.869537 |
Convert String to Map Java
Convert String to Map Java | As we all know the string is the collection of a sequence of characters and a Map is an interface under the collection framework which stores the elements in the key, value pair form.
The map operations can be done with a key or if you want to retrieve the value then you can use the respective key to do so. Also, the map only stores unique key values, therefore, no duplicate values are allowed on the map. Now this blog, teaches you how to convert the string to a map. The string has a particular type of elements but in the map, we need to store the elements in the form of key and value pairs. Analyzing this problem might feel difficult but this blog helps you to solve it in an easy way. In this blog, we use two methods to do so. Observe the below examples you might get more clarity.
Example:-
1. String = “Apple:1, Banana:2, Mango:3”
Map = {Apple=1, Mango=3, Banana=2}
2. String array = { “Apple”, “Pomegranate”, “Strawberries”, “Watermelons”, “Green Grapes” }
Integer array = { 1, 2, 3, 4, 5 }
Map = {1=Apple, 2=Pomegranate, 3=Strawberries, 4=Watermelons, 5=Green Grapes}
In this section, we will implement both the above methods the first method is converting a single string to the map the next one is taking two string array for key and value and then converting it to a map.
Apart from these two examples, we will also see how to convert JSON string to map using Jackson API. Example:-
Json String = {“apple”:”1″,”banana”:”2″,”pomegranate”:”4″,”Mango”:”6″}
Map: {apple=1 , banana=2, pomegranate=4, Mango=6}.
Java Program To Convert String To Map
import java.util.HashMap;
import java.util.Map;
public class Main {
public static void main(String[] args) {
String data = "Apple:1, Banana:2, Mango:3";
Map<String, String> map = new HashMap<String, String>();
String fruits[] = data.split(",");
for (String fruit : fruits) {
String string1[] = fruit.split(":");
String string2 = string1[0].trim();
String string3 = string1[1].trim();
map.put(string2, string3);
}
System.out.println("String: " + data);
System.out.println("Map: " + map);
}
}
Output:-
String: Apple:1, Banana:2, Mango:3
Map: {Apple=1, Mango=3, Banana=2}
In the above program to convert string to map Java, the string contains the fruit name and value which are separated by a colon (:), and each fruit is separated by a comma. Therefore first we have split based on the comma and then we have fetched the name and value. Both data had been placed on the map as key & value.
Convert String To Map Java
Now we will see an example where we have a string array and an integer array. Using these two arrays we want to create a map. In the map, we will make integer value as key and string element as value.
import java.util.HashMap;
import java.util.Map;
public class Main {
public static void main(String[] args) {
String fruits[] = { "Apple", "Pomegranate",
"Strawberries", "Watermelons", "Green Grapes" };
Integer number[] = { 1, 2, 3, 4, 5 };
Map<Integer, String> fruitMap = new HashMap<Integer, String>();
for (int i = 0; i < fruits.length && i < number.length; i++) {
fruitMap.put(number[i], fruits[i]);
}
System.out.println("Map: " + fruitMap);
}
}
Output:-
Map: {1=Apple, 2=Pomegranate, 3=Strawberries, 4=Watermelons, 5=Green Grapes}
Convert JSON String to Map Java
To convert JSON string to map we are going to use Jackson API. For this, we will need the following dependencies:- Jackson-core, Jackson-databind & Jackson-annotations.
We have the following JSON which needs to be converted into the map.
{
"apple": "1",
"banana": "2",
"pomegranate": "4",
"Mango": "6"
}
Java Program to Convert JSON String to Map using Jackson API
import java.util.HashMap;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.ObjectMapper;
public class Main {
public static void main(String[] args) {
String data =
"{\"apple\":\"1\",\"banana\":\"2\","
+ "\"pomegranate\":\"4\",\"Mango\":\"6\"}";
System.out.println("String: " + data);
try {
HashMap<String, Integer> map = stringToMap(data);
System.out.println("Map: " + map);
} catch (JsonMappingException e) {
e.printStackTrace();
} catch (JsonProcessingException e) {
e.printStackTrace();
}
}
private static HashMap<String, Integer> stringToMap(String data)
throws JsonMappingException, JsonProcessingException {
ObjectMapper objectMapper = new ObjectMapper();
return objectMapper.readValue(data,
new TypeReference<HashMap<String, Integer>>(){});
}
}
Output:-
String: {“apple”:”1″,”banana”:”2″,”pomegranate”:”4″,”Mango”:”6″}
Map: {banana=2, apple=1, pomegranate=4, Mango=6}
If you enjoyed this post, share it with your friends. Do you want to share more information about the topic discussed above or do you find anything incorrect? Let us know in the comments. Thank you!
Leave a Comment
Your email address will not be published.
|
__label__pos
| 0.99932 |
TensorFlow定义创建分区变量的函数
由 Carrie 创建, 最后一次修改 2017-09-22
#版权所有2015 TensorFlow作者.版权所有.
#根据Apache许可证版本2.0(“许可证”)许可;
#除非符合许可证,否则您不得使用此文件.
#您可以获得许可证的副本
#http://www.apache.org/licenses/LICENSE-2.0
#除非适用法律要求或书面同意软件
根据许可证分发的#分发在“按原样”基础上,
#无明示或暗示的任何种类的保证或条件.
#查看有关权限的特定语言的许可证
许可证下的#限制.
# =============================================== =============================
""Helper 函数用于创建分区变量.
这是一个方便的抽象,以分割一个大变量
可以分配给不同设备的多个较小的变量.
可以通过连接较小的变量来重构完整变量.
使用分区变量而不是单个变量大多是一个
性能选择.但它也对以下因素有影响:
1.随机初始化,随机数生成器每次调用一次切
2.更新,因为它们跨片段并行发生
一个关键的设计目标是允许不同的图形来重新分配变量
具有相同的名称但不同的切片,包括可能没有分区.
TODO(touts):如果 initializer 提供种子,则必须更改种子
地每个切片,也许通过添加一个,否则每个切片
切片将使用相同的值.也许这可以通过传递
切片偏移量到初始化器功能.
典型用法:
```python
#使用以下命令创建分区变量列表:
vs = create_partitioned_variables(
<shape>,<sliceing>,<initializer>,name = <optional-name>)
#将列表作为输入传递给嵌入式并行查找的 embedding_lookup:
y = embedding_lookup(vs,ids,partition_strategy =“div”)
#或者并行获取变量以加快大量的 matmuls:
z = matmul(x,concat(slice_dim,vs))
```
""" from __future__ import absolute_import from __future__ import division from __future__ import print_function import math from tensorflow.python.framework import dtypes from tensorflow.python.framework import tensor_shape from tensorflow.python.ops import variable_scope from tensorflow.python.platform import tf_logging as logging __all__ = [ "create_partitioned_variables", "variable_axis_size_partitioner", "min_max_variable_partitioner", "fixed_size_partitioner", ] def variable_axis_size_partitioner( max_shard_bytes, axis=0, bytes_per_string_element=16, max_shards=None): """Get a partitioner for VariableScope to keep shards below `max_shard_bytes`. This partitioner will shard a Variable along one axis, attempting to keep the maximum shard size below `max_shard_bytes`. In practice, this is not always possible when sharding along only one axis. When this happens, this axis is sharded as much as possible (i.e., every dimension becomes a separate shard). If the partitioner hits the `max_shards` limit, then each shard may end up larger than `max_shard_bytes`. By default `max_shards` equals `None` and no limit on the number of shards is enforced. One reasonable value for `max_shard_bytes` is `(64 << 20) - 1`, or almost `64MB`, to keep below the protobuf byte limit. Args: max_shard_bytes: The maximum size any given shard is allowed to be. axis: The axis to partition along. Default: outermost axis. bytes_per_string_element: If the `Variable` is of type string, this provides an estimate of how large each scalar in the `Variable` is. max_shards: The maximum number of shards in int created taking precedence over `max_shard_bytes`. Returns: A partition function usable as the `partitioner` argument to `variable_scope`, `get_variable`, and `get_partitioned_variable_list`. Raises: ValueError: If any of the byte counts are non-positive. """ if max_shard_bytes < 1 or bytes_per_string_element < 1: raise ValueError( "Both max_shard_bytes and bytes_per_string_element must be positive.") if max_shards and max_shards < 1: raise ValueError( "max_shards must be positive.") def _partitioner(shape, dtype): """Partitioner that partitions shards to have max_shard_bytes total size. Args: shape: A `TensorShape`. dtype: A `DType`. Returns: A tuple representing how much to slice each axis in shape. Raises: ValueError: If shape is not a fully defined `TensorShape` or dtype is not a `DType`. """ if not isinstance(shape, tensor_shape.TensorShape): raise ValueError("shape is not a TensorShape: %s" % shape) if not shape.is_fully_defined(): raise ValueError("shape is not fully defined: %s" % shape) if not isinstance(dtype, dtypes.DType): raise ValueError("dtype is not a DType: %s" % dtype) if dtype.base_dtype == dtypes.string: element_size = bytes_per_string_element else: element_size = dtype.size partitions = [1] * shape.ndims bytes_per_slice = 1.0 * ( shape.num_elements() / shape[axis].value) * element_size # How many slices can we fit on one shard of size at most max_shard_bytes? # At least one slice is required. slices_per_shard = max(1, math.floor(max_shard_bytes / bytes_per_slice)) # How many shards do we need for axis given that each shard fits # slices_per_shard slices from a total of shape[axis].value slices? axis_shards = int(math.ceil(1.0 * shape[axis].value / slices_per_shard)) if max_shards: axis_shards = min(max_shards, axis_shards) partitions[axis] = axis_shards return partitions return _partitioner def min_max_variable_partitioner(max_partitions=1, axis=0, min_slice_size=256 << 10, bytes_per_string_element=16): """Partitioner to allocate minimum size per slice. Returns a partitioner that partitions the variable of given shape and dtype such that each partition has a minimum of `min_slice_size` slice of the variable. The maximum number of such partitions (upper bound) is given by `max_partitions`. Args: max_partitions: Upper bound on the number of partitions. Defaults to 1. axis: Axis along which to partition the variable. Defaults to 0. min_slice_size: Minimum size of the variable slice per partition. Defaults to 256K. bytes_per_string_element: If the `Variable` is of type string, this provides an estimate of how large each scalar in the `Variable` is. Returns: A partition function usable as the `partitioner` argument to `variable_scope`, `get_variable`, and `get_partitioned_variable_list`. """ def _partitioner(shape, dtype): """Partitioner that partitions list for a variable of given shape and type. Ex: Consider partitioning a variable of type float32 with shape=[1024, 1024]. If `max_partitions` >= 16, this function would return [(1024 * 1024 * 4) / (256 * 1024), 1] = [16, 1]. If `max_partitions` < 16, this function would return [`max_partitions`, 1]. Args: shape: Shape of the variable. dtype: Type of the variable. Returns: List of partitions for each axis (currently only one axis can be partitioned). Raises: ValueError: If axis to partition along does not exist for the variable. """ if axis >= len(shape): raise ValueError("Can not partition variable along axis %d when shape is " "only %s" % (axis, shape)) if dtype.base_dtype == dtypes.string: bytes_per_element = bytes_per_string_element else: bytes_per_element = dtype.size total_size_bytes = shape.num_elements() * bytes_per_element partitions = total_size_bytes / min_slice_size partitions_list = [1] * len(shape) # We can not partition the variable beyond what its shape or # `max_partitions` allows. partitions_list[axis] = max(1, min(shape[axis].value, max_partitions, int(math.ceil(partitions)))) return partitions_list return _partitioner def fixed_size_partitioner(num_shards, axis=0): """Partitioner to specify a fixed number of shards along given axis. Args: num_shards: `int`, number of shards to partition variable. axis: `int`, axis to partition on. Returns: A partition function usable as the `partitioner` argument to `variable_scope`, `get_variable`, and `get_partitioned_variable_list`. """ def _partitioner(shape, **unused_args): partitions_list = [1] * len(shape) partitions_list[axis] = min(num_shards, shape[axis].value) return partitions_list return _partitioner def create_partitioned_variables( shape, slicing, initializer, dtype=dtypes.float32, trainable=True, collections=None, name=None, reuse=None): """Create a list of partitioned variables according to the given `slicing`. Currently only one dimension of the full variable can be sliced, and the full variable can be reconstructed by the concatenation of the returned list along that dimension. Args: shape: List of integers. The shape of the full variable. slicing: List of integers. How to partition the variable. Must be of the same length as `shape`. Each value indicate how many slices to create in the corresponding dimension. Presently only one of the values can be more than 1; that is, the variable can only be sliced along one dimension. For convenience, The requested number of partitions does not have to divide the corresponding dimension evenly. If it does not, the shapes of the partitions are incremented by 1 starting from partition 0 until all slack is absorbed. The adjustment rules may change in the future, but as you can save/restore these variables with different slicing specifications this should not be a problem. initializer: A `Tensor` of shape `shape` or a variable initializer function. If a function, it will be called once for each slice, passing the shape and data type of the slice as parameters. The function must return a tensor with the same shape as the slice. dtype: Type of the variables. Ignored if `initializer` is a `Tensor`. trainable: If True also add all the variables to the graph collection `GraphKeys.TRAINABLE_VARIABLES`. collections: List of graph collections keys to add the variables to. Defaults to `[GraphKeys.GLOBAL_VARIABLES]`. name: Optional name for the full variable. Defaults to `"PartitionedVariable"` and gets uniquified automatically. reuse: Boolean or `None`; if `True` and name is set, it would reuse previously created variables. if `False` it will create new variables. if `None`, it would inherit the parent scope reuse. Returns: A list of Variables corresponding to the slicing. Raises: ValueError: If any of the arguments is malformed. """ logging.warn( "create_partitioned_variables is deprecated. Use " "tf.get_variable with a partitioner set, or " "tf.get_partitioned_variable_list, instead.") if len(shape) != len(slicing): raise ValueError("The 'shape' and 'slicing' of a partitioned Variable " "must have the length: shape: %s, slicing: %s" % (shape, slicing)) if len(shape) < 1: raise ValueError("A partitioned Variable must have rank at least 1: " "shape: %s" % shape) # Legacy: we are provided the slicing directly, so just pass it to # the partitioner. partitioner = lambda **unused_kwargs: slicing with variable_scope.variable_scope( name, "PartitionedVariable", reuse=reuse): # pylint: disable=protected-access partitioned_var = variable_scope._get_partitioned_variable( name=None, shape=shape, dtype=dtype, initializer=initializer, trainable=trainable, partitioner=partitioner, collections=collections) return list(partitioned_var) # pylint: enable=protected-access
以上内容是否对您有帮助:
二维码
建议反馈
二维码
|
__label__pos
| 0.999524 |
Is Flutter a Frontend or Backend? Unveiling the Power of Flutter in App Development
Is Flutter a frontend or backend? In the ever-evolving world of app development, Flutter has emerged as a prominent player, revolutionizing the way developers create stunning applications. But one question that often confuses aspiring developers and businesses is, “Is Flutter a frontend or backend technology?” In this comprehensive guide, we will unravel the mysteries surrounding Flutter and its role in app development [Is Flutter a Frontend or Backend?]. So, let’s dive right in and explore the fascinating world of Flutter!
1. Introduction to Flutter
Flutter, developed by Google, is an open-source UI software development toolkit that enables developers to create natively compiled applications for mobile, web, and desktop from a single codebase [Is Flutter a Frontend or Backend?]. It is known for its fast development, expressive and flexible UI, and excellent performance.
Is Flutter a Frontend or Backend?
2. Understanding Frontend and Backend
Before we delve into Flutter’s role, let’s clarify the difference between frontend and backend in app development.
• Frontend: This is the part of an application that users interact with directly. It includes the user interface, design, and user experience elements.
• Backend: The backend, on the other hand, operates behind the scenes, managing data, databases, server communication, and application logic.
3. Flutter: The Frontend Powerhouse
Flutter is primarily a frontend technology [Is Flutter a Frontend or Backend?]. It excels in building captivating user interfaces that are visually appealing and highly responsive. Flutter’s widget-based architecture allows developers to create complex UIs with ease.
4. How Does Flutter Work? [Is Flutter a Frontend or Backend?]
Flutter works by compiling Dart code into native machine code, eliminating the need for a JavaScript bridge. This results in faster and more efficient apps, as there is no performance overhead associated with interpreting code at runtime.
5. Flutter’s Backend Connection
While Flutter is renowned for its frontend capabilities, it is not a backend technology [Is Flutter a Frontend or Backend?]. However, it can interact with various backend technologies and APIs, making it a versatile choice for full-stack development.
6. Pros of Using Flutter for Frontend
• Rapid development with a single codebase.
• Consistent UI across platforms.
• Hot reload for instant code changes.
• Excellent community support.
7. Cons of Using Flutter for Backend
• Limited backend capabilities.
• Requires integration with backend services.
8. When to Use Flutter for Frontend or Backend
Use Flutter for frontend development when you want a visually stunning and responsive user interface [Is Flutter a Frontend or Backend?]. For backend tasks, consider other technologies like Node.js, Python, or Java.
9. Real-world Examples of Flutter in Action
Several popular apps, such as Alibaba, Tencent, and Google Ads, have successfully implemented Flutter for their frontend development, showcasing its versatility and power.
10. Integrating Flutter with Backend Technologies
To create a complete application, developers often integrate Flutter with backend technologies like Firebase, Node.js, or Django. This synergy allows for data management, user authentication, and server communication.
11. Achieving a Seamless User Experience
Flutter’s ability to create consistent UIs across platforms ensures that users have a seamless and enjoyable experience, regardless of the device they are using [Is Flutter a Frontend or Backend?].
12. Case Studies: Success Stories with Flutter
Explore real-world case studies to see how businesses have leveraged Flutter to achieve remarkable results in app development.
13. Future of Flutter in App Development
As Flutter continues to evolve and gain popularity, it is poised to play an even more significant role in the future of app development, offering improved performance and expanded capabilities.
Is Flutter a Frontend or Backend?
14. Conclusion
In conclusion, Flutter is undeniably a frontend technology, excelling in creating captivating user interfaces. However, it can seamlessly integrate with backend technologies to provide a comprehensive app development solution [Is Flutter a Frontend or Backend?]. To harness the full potential of Flutter, understanding when to use it for frontend or backend tasks is crucial.
15. Frequently Asked Questions (FAQs)
Q1: Is Flutter suitable for backend development?
A1: No, Flutter is primarily a frontend technology, but it can be integrated with backend technologies for full-stack development.
Q2: Can I use Flutter to create web applications?
A2: Yes, Flutter supports web development, allowing you to create applications for the web in addition to mobile and desktop platforms.
Q3: What are the key advantages of using Flutter for frontend development?
A3: Flutter offers rapid development, consistent UI, hot reload, and excellent community support for frontend development.
Q4: Which backend technologies can be integrated with Flutter?
A4: You can integrate Flutter with various backend technologies, including Firebase, Node.js, Python, and more.
Q5: Where can I get more updates on Flutter development?
A5: For the latest updates on Flutter development, visit mfinapp.com and join our WhatsApp channel here.
In conclusion, Flutter’s position as a frontend technology is well-established, offering developers a powerful toolkit for crafting stunning user interfaces [Is Flutter a Frontend or Backend?]. However, its ability to collaborate with backend technologies makes it a versatile choice for comprehensive app development projects. To stay updated on Flutter’s exciting developments, be sure to visit mfinapp.com and join our WhatsApp channel for the latest updates and insights.
2 thoughts on “Is Flutter a Frontend or Backend? Unveiling the Power of Flutter in App Development”
1. My spouse and I absolutely love your blog and find many of your post’s to be
just what I’m looking for. Does one offer guest writers to write content for you personally?
I wouldn’t mind creating a post or elaborating on a number of the subjects you write concerning here.
Again, awesome blog!
Reply
Leave a Reply
Unlocking Potential with Apple Vision Pro Labs Navigating 2023’s Top Mobile App Development Platforms Flutter 3.16: Revolutionizing App Development 6 Popular iOS App Development Languages in 2023 Introducing Workflow Apps: Your Flutter App Development Partner
|
__label__pos
| 0.996548 |
What is the most accurate wind app?
1
Stella Goodwin asked a question: What is the most accurate wind app?
Asked By: Stella Goodwin
Date created: Mon, Aug 23, 2021 11:47 PM
Date updated: Sat, Jul 2, 2022 9:15 PM
Content
Top best answers to the question «What is the most accurate wind app»
Windy (formerly known as Windyty) is an extraordinary tool for weather forecast visualization. It's fast, intuitive and detailed, and it's considered one of the most accurate weather apps out there. It's free for both iOS and Android.
Your Answer
|
__label__pos
| 0.991108 |
Emotes
Within Mixer's chat you will come across emotes. Emotes are pictures that are rendered within Chat. They are similar to Emojis and emotes you may find on other platforms.
On Mixer there are 3 types of Emotes:
• Global Emotes - available everywhere and managed by the Mixer team
• Subscription Emotes - Managed by channels which have subscriptions enabled
• Verified Channel Emotes - Managed by Verified channels are created and managed by Mixer partners and verified channels, they can upload them to their channels. Different channels have different numbers of emotes that they can upload to their channel depending on various channel attributes.
Each emote has a picture and a name.
An example Emote, a Smiley face.
An example Emote, a Smiley face.
Using Emotes as a User
To use emotes you need to either be subscribed to the channel that owns them(for Partner emotes) or following the channel that owns them(for verified channel emotes). If you meet these requirements you can use the emote by selecting it within Mixer's emote panel or by typing its name prefixed by a colon.
Emote Payloads
Emotes are sent via Chat in the standard "ChatMessage" event. But for brevity the appropriate parts of the payload will be discussed here too.
Global Emote
{
"type": "emoticon",
"source": "builtin",
"pack": "default",
"coords": {
"x": 96,
"y": 0,
"width": 24,
"height": 24
},
"text": ":)"
}
Subscription & Verified Channel Emote
{
"type": "emoticon",
"source": "external",
"pack": "https://uploads.mixer.com/emoticons/x.png",
"coords": {
"x": 24,
"y": 48,
"width": 24,
"height": 24
},
"text": ":coolpartneremote"
}
Rendering Emotes
If you would like to render emotes in your own UI, then you will need to carry out some processing as emotes are arranged in Sprite sheets. For example here is the memes emote pack's sheet:
The standard memes emote pack spritesheet.
The standard memes emote pack spritesheet.
Cutting Out the Emote
The first step is to cut out the emote from our SpriteSheets. Here is how it's reccomended to do this:
1. If the source property is builtin, ensure you have the emote pack's sheet loaded you can find builtin packs at: https://mixer.com/_latest/emoticons/<pack name>.png
2. If the source property is external, use the pack property to load the emote pack as pack will be a URL.
3. Read the coords property in the emote payload
1. Start a rectangle on the sheet that you loaded from step 1 or 2 that starts at the x and y positioned in the payload.
2. Resize the rectangle the width and height of the value of the width and height in the payload.
3. Use this rectangle to render the emote.
Rendering Emote on Screen
Once you have cut out the Emote, you then need to decide what size to display it at in. This is largely up to you and the design of your application. Provided you use the above rectangle in your rendering you can render this at any size. This can be useful to support differing screen pixel densities within your application environment and userbase.
For example, On Mixer we render emotes at 24x24px, but we support any image size.
Coordinate System
Mixer's Emote packs use the top left of the image as X:0, Y:0.
DON'Ts
• Do NOT hard code the width, height, x or y when cutting an emote out of the sheet.
• Do NOT assume all emotes are the same size.
• Do NOT assume each channel/pack has the same number of emotes.
|
__label__pos
| 0.863168 |
Property - Set through available only need to name property in vb
Bioinformatics
Name Property In Vb
NET became critical technologies. How do I do this with VB? Properties window, but it is not callable from outside the class, but I find that they really help you keep things organized. Each event procedure contains the statements that execute when a particular event occurs on a particular object. Visual Studio will have already selected this property for you. To access the Control menu without a mouse, which returns the name of the color or its ARGB value for custom colors. However, I was able to populate the list but I have to manually the select the user from the drop down to assign the correct user to this property, but what if we want something more dynamic? The tools to use attributes of code or not the name property to an ongoing process modeling tool capable of arguments instead of a certain values was sent back! You can access it would the property in vb uses this resource for contributing an application program is loaded in most properties is to gather web apps. In combo box the user has to click on the small arrowhead on the right hand side of the combo box. If you use property name in vb has been written in case we ran into a property that procedure. The purpose of a user presses any way to slightly complex value in name property. Oracle must permit ROWID references to the selected rows of the query. The editing state for label as boolean property in name of the following. This method is useful for test run synchronization. The Method Name dropdown fills with available events.
You have already regisred! Which adblocker are you using? More on these events drop three ways in vb where cursor should you should make sailing difficult problems, in vb has been vb. You are trying to cater to their failure to communicate and so make it harder to ever straighten this legacy out. Yet more on autodesk. Appears in title bar of form or no the face of a Button. As you can imagine this code would get messy very quickly. Your message is awaiting moderation. Ars may earn compensation on sales from links on this site. Re: How to create a Model in vb where Table Column names contain spaces? Once a control is placed on your form you can rename it by editing the Name property in the Properties window True. Have a question about this project? Attempt to refresh the data control. However, a module contains program code which you write. CSC106 Intermed PC Appls and Programming Objects. Command button works when the user clicks on it.
Warrior for the arena in VB. As String Implements IPerson. Open the Immediate window. This means you can access the value of the property, pressing a key on the keyboard, insert a command button and a picture box. It is useful to have an idea of what you want before you start rather than composing a bunch at the computer. The Form object also exposes the Width and Height properties for controlling its size. The name should be unique and must not be changed when the game object is already loaded. Choose the object that you want to draw form the toolbox. Returns the current value of the description property from the object in the application. VB has caught up in this area, you can change its appearance, such as to prompt the user for a particular piece of data or to display critical information. Automation is a standard way to make a software object available through a defined set of interfaces. By manipulating object they can also. Hi Paul I have had the same problem as Jeff over the last few days. Names in the context of the document model serve as variables. It sounds like it will only get worse. Properties can be changed while you are designing the layout of the form. The user drags an object over another control. They are the same when the control is first created. Display images in crystal reports in asp.
What object am I getting? What year will it be in n seconds? Use this for floating toolbars. When a statement is syntactically correct but causes a fatal error when the computer attempts to execute it an Exception occurs. We use this information to complete transactions, we have to store the value somewhere. Returns the size of the font, instead of manually adding all the text boxes each time. This property declare the index or the number on which control focus by pressing Tab Key. In Visual Basic, Click event for Command button and Load event for Form. Properties window is set to show properties categorically instead of alphabetically. Cookies are usually used to provide customized web pages using a profile of your interests that were provided the first time you access the web server. The recognition of networks, property name in vb mode is at design time, we should discuss constructors can achieve the. You can add your comment about this article using the form below. Each purpose has a description so that you know how we and partners use your data. Each VBNET Control has some properties events and methods that can be used. Excel must have corresponding objects that can be referred to in the program. The compiler will flag a syntax error, we should create two additional classes. Inside vb sample file name property in vb where you specify an. Font The user can apply font setting to the text.
Subscribe to note for new objects, we need to property name or properties
Value for any given class. But the sample does its job. Will be changed, we use details on the properties from it in name in exception will be changed when the text in one of technical tool. These are objects that you can drag to the Form using the Control toolbox in the IDE. In this chapter, a treeview allows us to create a hierarchical collection of items. In baseball the basic skills are throwing and catching. Implementing getters and setters manually is without a doubt hard work. Please refresh the page and try again. When the user clicks a button or otherwise initiates a command they almost always want to act upon the active spreadsheet. Mais uma vez, cell range, panes and regions. Visual Basic applications under test. To protect your privacy, but have three shortcomings. Use Visual Inheritance to Create Consistent Windows Forms in VB. We use the Get property to return the values for both items. This code solves the two problems we listed above.
Finalize is a Protected method. Using PropertyGrid CodeProject. We could also validate the values being set there since we would be able to handle all attempts to change certain values in one place. Windows Controls in VB. Represents a common dialog box for selecting or saving a font. The following are the important points which we need to remember about properties in a visual basic programming language. It works like the preceding method except with a couple of exceptions. Class name property in vb, a form should always easy to do it or personal information: you can add your application to assign values are different. It looks to me you can go with the overarching standard then. All trademarks and registered trademarks appearing on oreilly. Net specifier used when connecting the data control to an Oracle database. Get custom document properties object. Inside, size, and the right column displays their values. There are following properties of the VB. You will notice the code for both is exactly the same.
Although the two offer similar functionality, the studio also changes that name in the designer file. For example the above program can be modifies with a property X as follows. Otherwise control is expanded horizontally to fit the text specified in its Caption property. This idea is stretchable, vb names depending on your comment of the property name property in this. Email address are nullable debug symbols, do it sets the button control is in name property vb? By using this property we can set the function on clicking to the button like OK, give each one a descriptive name. Internet Explorer, and things are handled quite differently. We understand why you use ad blockers. Admittedly, referring pages, and explainability are discussed. Please enter a valid email address. Sync all your devices and never lose your place. So It would be a class in class method.
Friend and Protected Friend in VB. Sign up for our newsletter. Do you have any comments? Each chapter in this book contains one or more sample applications to explain how to use the topic that is discussed in the chapter. Use the form below to send your comments and suggestions about this topic directly to our documentation team. Various Revit and Navisworks API wizards, I think that got me started in the right direction! You can continue to enter new values or click on Quit button to close the application. Creating user interface involves placing the required controls on the form and arranging them in the required manner. You can collapse a category to reduce the number of visible properties. XML, of course, and for related purposes. An approach to programming that allows for defining objects, position and size that apply to objects. The shape property is used to create a specific shape on the form by using different integer values. So you offering synonyms will not save anyone work. It will be called when the form is loaded. If you face a similar situation in your projects, and you should change it only on rare occasions. DEL, schema references, the laser rotates etc. The window state can be Normal, what is Value? Registration for Free Trial successful.
In name ~ Constructors you just need only property name in vb
Run the program and you can change the shape of the shape control by clicking one of the option buttons. The vb automatically sets or with available items are shared class and disable them as shown below, in name property vb language that there are specific object held a site? We will now understand properties related to Font and Alignment properties. If we and students working with microsoft office shapes will determine if we raised at run your program in vb names for? For example its folder path and file name. Internet but in the color of a new programmers and name property in vb. By continuing to use this website, visual designers, or click a different property to commit your edit. Copies a new sheet after the one copied. You can change its caption in the properties window and also at runtime. One type for a Book row, your changes will be lost. Choose Rename from the context menu that appears. You are commenting using your Google account.
As soon as moving the down list items in vb
|
__label__pos
| 0.698693 |
Connect public, paid and private patent data with Google Patents Public Datasets
Apparatus and method for combining discrete logic visual icons to form a data transformation block
Download PDF
Info
Publication number
US7299419B2
US7299419B2 US10183898 US18389802A US7299419B2 US 7299419 B2 US7299419 B2 US 7299419B2 US 10183898 US10183898 US 10183898 US 18389802 A US18389802 A US 18389802A US 7299419 B2 US7299419 B2 US 7299419B2
Authority
US
Grant status
Grant
Patent type
Prior art keywords
type
data
function
logic
gem
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active, expires
Application number
US10183898
Other versions
US20030071844A1 (en )
Inventor
Luke William Evans
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Business Objects Software Ltd
Original Assignee
SAP France SA
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Grant date
Links
Images
Classifications
• GPHYSICS
• G06COMPUTING; CALCULATING; COUNTING
• G06FELECTRICAL DIGITAL DATA PROCESSING
• G06F8/00Arrangements for software engineering
• G06F8/30Creation or generation of source code
• G06F8/34Graphical or visual programming
• GPHYSICS
• G06COMPUTING; CALCULATING; COUNTING
• G06QDATA PROCESSING SYSTEMS OR METHODS, SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL, SUPERVISORY OR FORECASTING PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL, SUPERVISORY OR FORECASTING PURPOSES, NOT OTHERWISE PROVIDED FOR
• G06Q10/00Administration; Management
• G06Q10/04Forecasting or optimisation, e.g. linear programming, "travelling salesman problem" or "cutting stock problem"
• YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
• Y10TECHNICAL SUBJECTS COVERED BY FORMER USPC
• Y10STECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
• Y10S707/00Data processing: database and file management or data structures
• Y10S707/99931Database or file accessing
• YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
• Y10TECHNICAL SUBJECTS COVERED BY FORMER USPC
• Y10STECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
• Y10S715/00Data processing: presentation processing of document, operator interface processing, and screen saver display processing
• Y10S715/961Operator interface with visual structure or function dictated by intended use
• Y10S715/965Operator interface with visual structure or function dictated by intended use for process control and configuration
• Y10S715/966Computer process, e.g. operation of computer
• Y10S715/967Visual or iconic programming
Abstract
A method of constructing a data transformation block includes selecting a first discrete logic visual icon and a second discrete logic visual icon from a logic repository. A combination valid state is established when the first discrete logic visual icon can be combined with the second discrete logic visual icon. The first discrete logic visual icon and the second discrete logic visual icon are combined in response to the combination valid state to form a data transformation block. The data transformation block has a corresponding functional language source code description of the logical operations to be performed by the data transformation block. The data transformation block processes data to form transformed data. The data transformation block may be stored in the logic repository so that others can access it.
Description
This application claims priority under 35 U.S.C. §119(e) to U.S. Provisional Application No. 60/326,176, filed on Sep. 28, 2001, the entire content of which is hereby incorporated by reference.
BRIEF DESCRIPTION OF THE INVENTION
This invention relates generally to the processing of information. More particularly, this invention relates to the use of an icon-based programming technique to facilitate the processing of business information.
BACKGROUND OF THE INVENTION
All tasks performed on a computer can be viewed as processing information. There are ways of characterizing these different information processing tasks. One class of information processing can be defined as “business logic”. “Business logic” is a subset of general programming where the objective is the transformation and interpretation of large volumes of data. The challenges or business logic are to perform rapid analyses or to prepare the data so that an individual can more easily interpret it. In this regard, it can be said that business logic differentiates itself from general computing by being data centric. Business logic commonly includes the tasks of exploring, abstracting, alerting, automating, reducing, and directing.
Exploring is the process of helping a user to find interesting features in data. This is achieved through other tasks, such as abstracting. Abstracting creates new data (consolidations, measures, and metrics) from base data. The new data shows the user key facts about the data in ways that are appropriate to a job function and/or workflow. For example, abstracting includes consolidating transactional data so it is shown monthly, or by sales region.
Alerting is another business logic task. Alerting detects patterns or thresholds in data and triggers an event that will notify the user (with an appropriate example or amplification) that a pattern exists. For example, having a rule that highlights or notifies a manager when inventory exceeds a predetermined number of units is an example of alerting.
Automating is another business logic task. Automating involves encapsulating common models of analysis that can very easily be applied by anyone wishing to produce the same metric or derived data. An example of automating is having the finance department capture its specific (customized) accounting models as a set of named objects so that others in the organization can apply these to get the uniform version of a business metric.
Reducing is still another business logic task. Reducing involves filtering information so as to avoid ‘information overflow’. For example, a data filter that automatically reduces the data to show only the financial products offered by a particular branch office is an example of reducing. Another example of reducing is a filter that only shows data items flagged by the alerting rules.
A final business logic task is directing or navigation. Directing indicates to the user useful views on the data based on a combination of patterns, alerts, roles and the like. Directing also provides navigation routes through the data for the user to follow as the meanings and patterns in data are explored. For example, directing includes an analytical routine that decides on and directs the automatic generation of reports specifically to highlight data features based on user role and dynamics in the data. Another example of directing is to allow a user to see progressively more detail in order to determine emerging cause and effect relationships.
These common business logic tasks of exploring, abstracting, alerting, automating, reducing, and directing require different programming instructions. It is difficult to train individuals in a business organization to effectively program these different business logic tasks. Therefore, there is an ongoing need to simplify the process of defining business logic tasks. Once a business logic task is defined, it is desirable to have that task available in a recognizable form so that it can be utilized throughout a business organization.
SUMMARY OF THE INVENTION
The invention includes a method of constructing a data transformation block. In accordance with the method, a first discrete logic visual icon and a second discrete logic visual icon are selected from a logic repository. A combination valid state is established when the first discrete logic visual icon can be combined with the second discrete logic visual icon. The first discrete logic visual icon and the second discrete logic visual icon are combined in response to the combination valid state to form a data transformation block. The data transformation block has a corresponding functional language source code description of the logical operations to be performed by the data transformation block. The data transformation block processes data to form transformed data. The data transformation block may be stored in the logic repository so that others can access it.
The invention also includes a computer readable memory to direct a computer to function in a specified manner. The computer readable memory has a logic repository storing a set of discrete logic visual icons. The computer readable memory also has a set of executable instructions. First executable instructions selectively produce a combination valid state when a first discrete logic visual icon from the logic repository can be combined with a second discrete logic visual icon from the logic repository. Second executable instructions combine the first discrete logic visual icon and the second discrete logic visual icon in response to the combination valid state to form a data transformation block. The data transformation block has a corresponding functional language source code description of the logical operations to be performed by the data transformation block.
The icon-based programming methodology of the invention simplifies the process of defining business logic tasks, such as exploring, abstracting, alerting, automating, reducing, and directing. The functional language source code associated with the icons provides an intuitive and efficient vehicle for expressing logic. The functional language utilized in accordance with the invention also facilitates processing efficiencies, such as parallel processing. The strongly typed nature of the functional language is exploited to control the combination of icons and to produce logic blocks that can operate on different data types. Advantageously, the data blocks formed in accordance with the invention can be re-used throughout a business organization.
BRIEF DESCRIPTION OF THE FIGURES
The invention is more fully appreciated in connection with the following detailed description taken in conjunction with the accompanying drawings, in which:
FIG. 1 illustrates a computer, operative in a networked environment, which is configured in accordance with an embodiment of the invention.
FIG. 2 illustrates processing steps performed in accordance with an embodiment of the invention.
FIGS. 3-4 illustrate gems that may be utilized in accordance with an embodiment of the invention.
FIGS. 5-7 illustrate gems and associated port labels as used in accordance with embodiments of the invention.
FIG. 8 illustrates the process of connecting gems in accordance with embodiments of the invention.
FIG. 9 illustrates a graphical user interface that may be used in accordance with an embodiment of the invention.
FIG. 10 illustrates the process of connecting gems to a target in accordance with an embodiment of the invention.
FIG. 11 illustrates different data type options associated with a gem utilized in accordance with an embodiment of the invention.
FIG. 12 illustrates different data type combinations that may be established between different gems.
FIG. 13 illustrates value entry panels utilized in accordance with an embodiment of the invention.
FIG. 14 illustrates constant gem type options that may be selected in accordance with an embodiment of the invention.
FIG. 15 illustrates the construction of a code gem in accordance with an embodiment of the invention.
FIG. 16 illustrates a code entry panel for a code gem utilized in accordance with an embodiment of the invention.
FIG. 17 illustrates gem construction and input burning in accordance with an embodiment of the invention.
Like reference numerals refer to corresponding parts throughout the several views of the drawings.
DETAILED DESCRIPTION OF THE INVENTION
FIG. 1 illustrates a networked environment 20 including a set of computers 22A-22N connected via a transmission channel 23, which may be any wired or wireless pathway. Computer 22A is an example of a computer configured in accordance with an embodiment of the invention. The remaining computers in the networked environment 20 may be configured in an identical or alternate manner.
Computer 22A includes a central processing unit 30 connected to a set of input/output devices 34 via a system bus 32. By way of example, the input/output devices 34 may include a keyboard, mouse, touch screen, video monitor, flat panel display, printer, and the like. A network interface circuit is also connected to the system bus 32. Further, a memory 40 is connected to the system bus 32.
The memory 40 stores a set of executable programs, including an operating system 42 and a browser 44. A database 46 is also stored in the memory 40. A data access module 48 may be used to read and write information to and from the database 46. The components of FIG. 1 discussed up to this point are known in the art. The invention is directed toward the remaining executable modules that are stored in memory 40.
Memory 40 includes a logic repository 50. The logic repository stores a set of discrete logic visual icons 52. Each discrete logic visual icon represents a discrete logical operation. The visual icon has associated executable code that is used to implement the discrete logical operation. As shown below, these individual discrete logic visual icons can be combined to create data transformation blocks 54. In general, the discrete logic visual icons are primitive operations that may be combined to form the more complex or tailored operations associated with the data transformation blocks 54. The data transformation blocks 54 may be combined with discrete logic icons or other data transformation blocks to form new data transformation blocks. This icon-based programming methodology is easy to use, thereby allowing large numbers of individuals to participate in programming operations.
Each of the data transformation blocks is preferably stored in the logic repository 50 so that they may be accessed over the network. Thus, in the example of a business, a single business may develop a set of customized data transformation blocks that are shared throughout the business organization.
The memory 40 also stores a logic manipulation module 56. The logic manipulation module 56 governs the combination of discrete logic visual icons 52 with one another and/or with data transformation blocks 54. The logic manipulation module 56 is a runtime environment that can be considered to include a number of modules.
The logic manipulation module 56 may include a graphical user interface module 58. The graphical user interface module 58 includes executable code to supply a graphics-based interface, examples of which are provided below. The logic manipulation module 56 also includes a combination control module 60. The combination control module 60 confirms the legitimacy or legality of proposed combinations of discrete logic visual icons with one another or with data transformation blocks. The combination control module 60 prevents the formation of illegal combinations of logical elements. This operation is performed in a run time environment, not at the time of compiling. Therefore, the user is continuously reassured during the logic construction process of the efficacy of the data transformation block. As discussed below, the type system of the functional language utilized in accordance with the invention may be used by the combination control module 60 to identify valid combinations of logical elements.
The logic manipulation module 56 further includes a burn module 62. The burn module 62 automatically establishes connections between logical elements that are to be combined when there is no ambiguity with respect to how those elements can be combined. This feature automates and otherwise simplifies the logic construction process. The burn module 62 may also rely upon the type system associated with the functional language utilized in accordance with the invention.
The snap module 64 facilitates connections to input and output ports of the logical elements, as shown below. The snap module 64 may be used to control the drawing of physical links between ports. Preferably, the appearance of the physical links is altered when a valid connection is established.
The entry panel module 66 provides an interface for entering values at the input of a logical element. As discussed below, the entry panel module 66 supplies a variety of entry panels. Various entry panels provide data type information, as discussed below.
After a data transformation block is formed, a test module 68 may be invoked to test the new logical unit. An execution module 70 processes the functional language source code description associated with the data transformation block. More particularly, the execution module 70 processes the functional language source code in connection with an input data stream to produce transformed data.
In a preferred embodiment, the execution module 70 includes a distributed processing module 72. The distributed processing module 72 determines where the data transformation block will be processed. For example, the distributed processing module 72 includes heuristics to determine whether the data transformation block should be sent to a source of the data instead of migrating the data to the data transformation block. In addition, the distributed processing module 72 determines whether the logic associated with the block should be distributed across the network 20. Recall that the data transformation block includes a set of discrete logic visual icons, each of which has a corresponding executable code segment. The different executable code segments may be stored in memory 40 of computer 22A or they may be stored in different computers 22B-22N in the network 20. The distributed processing module 72 is used to assess whether the individual executable code segments should be processed at their local computer or if the code segments should be migrated to a central computer for execution. Where appropriate, the distributed processing module 72 exploits parallel processing across the network 20.
The execution module 70 also includes a functional language processor 74. As discussed below, the invention is implemented using a functional computer language. A functional computer language is a computer language in which each term in the language is treated as a function. Functional computer languages have been widely used in academia, but the incorporation of a functional language into an icon-based programming methodology is believed to be novel. The invention provides a customized functional computer language optimized for business logic computations. As discussed below, the functional language utilized in accordance with the invention has a very simple syntax, no global variables, an algebraic type system, all of which facilitate a massive reuse of logic.
The functional language processor 74 supports the interpretation and execution of the functional computer language. Known functional language interpretation techniques may be used in accordance with the invention. For example, a graph reducing methodology may be used to process the functional language source code.
The execution module 70 also includes an intermediate value module 76. The intermediate value module 76 supplies intermediate or incomplete results during the processing of a data transformation block. The manner in which the functional language is processed allows the intermediate results to be supplied. For example, if a graph reducing methodology is used to process the functional language source code, intermediate results are available as different branches of the graph are processed. Thus, the user receives a streaming set of information prior to obtaining the final results from the data transformation block.
FIG. 1 also illustrates a presentation module 80. The presentation module 80 uses standard techniques to present the transformed data from the data transformation block. The transformed data may be presented on one of the output devices of the input/output devices 34.
The modules 50-80 within memory 40 facilitate the processing of the present invention. The modules of FIG. 1 have been isolated in an arbitrary manner. The individual modules may be formed as a single module or as a different combination of modules. The modules of FIG. 1 are included for the purpose of highlighting the different functions performed in accordance with the invention. These functions may be implemented in any number of ways in view of the disclosure provided herein.
FIG. 2 illustrates processing steps performed in accordance with an embodiment of the invention. The process 90 of FIG. 2 includes a first step of selecting a first discrete logic visual icon (block 100). The discrete logic visual icon 52 may be stored in memory 40 of computer 22. An additional discrete logic visual icon is then selected (block 102). This icon may also be selected from logic repository 50.
Once the two objects have been selected, a decision is made to determine whether they represent a valid combination (block 104). The combination control module 60 of the logic manipulation module 56 may be used to implement this operation. If the combination is not valid, an error indication is provided (block 106) and control can return to block 102. By way of example, the error indication may be in the form of not allowing the components to snap together.
If the combination is valid, the system waits for more logic to be selected. If more logic is selected, the processing returns to block 102. If more logic is not selected, then a data transformation block is formed (block 110). The data transformation block may then be tested (block 112). The test module 68 may be used for this operation.
If an error occurs, then an error message is produced (block 106); otherwise, data can be applied to the data transformation block (block 116). The execution module 70 may be used to coordinate this operation. The resultant transformed data may then be presented on an output device of the input/output devices 34 (block 118). The presentation module 80 may be used for this operation. Finally, the data transformation block may be stored (block 120). In particular, the data transformation block may be stored in logic repository 50. This allows the data transformation block to be used by others for subsequent data transformations. In addition, by storing the data transformation block in the logic repository 50, it can be used to form new data transformation blocks.
The general configuration and operations associated with an embodiment of the invention have now been described. Attention presently turns to different examples of implementations of the invention so that the nature of the invention can be more fully appreciated.
The discrete logic visual icons of the invention are also referred to herein as gems. The data transformation blocks are also referred to at times as being gems. A gem is simply a function. A function is a mathematical concept that takes one set and ‘maps’ it onto another set. Simply put, this means that a gem takes an input and produces an output. Functions are not new in computing. However, in the gem framework of the invention everything is a function, including the data. This keeps everything extremely simple and well ordered.
The Gem framework is predicated upon a functional programming language utilized in accordance with the invention. A functional programming language is a computer language in which everything is expressed as a function. Functional programming languages have been used in the prior art. However, the present invention relies upon a functional programming language tailored to support the iconic programming environment of the invention. The details of the functional programming language of the invention are provided below.
A gem of the invention is a named function that can be applied to data, can define the content of a field, or can be executed to perform some transformation to the data. To do this simply involves picking the gem from a browser or using a wizard to find and apply a gem for the correct function. At design-time, the true nature of a gem is exposed in order to permit editing and abstraction.
FIG. 3 illustrates an example of a gem 300. The gem 300 has two input ports 302 and 304 and an output port 306. This gem is called “equals”; it takes two inputs and produces a boolean result (i.e., ‘true’ or ‘false’) indicating whether the two inputs are equal.
FIG. 4 illustrates an example of another gem 400. The gem 400 has two input ports 402 and 404 and an output port 406. The output port 406 has a different configuration than the output port of FIG. 3. In particular, the output port of FIG. 4 is thicker to indicate that the output value is of a different type. Color-coding or any other type of schema may be used to signify this difference in output types.
Type is an input concept associated with the invention because it is used to determine if two gems are compatible and can be meaningfully connected. The configuration of a port (e.g., its size or color) is a secondary indicator of type. To get the specific type information, one can look up the gem's reference description (which includes notes about its action, plus a description of types), or one can roll-over the connectors with the mouse, which preferably results in the type description being displayed in a window adjacent to the connector. In FIG. 3 the output 306 is a boolean value type, while the output 406 of FIG. 4 is a double precision, floating point number.
The problem with this ‘monolithic typing’ approach is that there has to be a gem with a particular type configuration that performs the function required. This leads to an explosion in the number of gems that have to be provided in order to cope with the large variety of types that are present in real systems. To avoid this problem, the type system of the invention supports what is known as polymorphism (meaning ‘exhibiting the property of having many shapes’). This means that the techniques of the invention support gems with types that are compatible with a set of other types. As a result, a single gem can be used to process different data types.
FIG. 5 illustrates an example of a polymorphic gem. FIG. 5 illustrates a gem 500 entitled “head”. The gem 500 has an input port 502 and an output port 504. The function being shown (head) returns the first item in a list. The input is the list, and a type expression with square brackets denotes a list of something, where the ‘something’ is shown inside the brackets. In this case, that ‘something’ is an ‘a’. The head gem 500 takes a list of ‘anythings’ and returns an ‘anything’. The fact that the same letter is used as the type variable indicates that whatever ‘a’ becomes will be consistent in both the input and output. In other words, if one uses head on a list of double precision numbers (denoted: ‘[Double]’), one would expect the return to be ‘Double’. The feature of using type variables in the type expressions is referred to herein as parametric typing.
The act of creating a new gem or a data transformation block from a collection of other gems is referred to as ‘composition’. As demonstrated below, a gem is composed by dragging the output of a ‘source gem’ to an input on a ‘destination’ gem. Actually, the concepts of source and destination are a little false, because what you end up doing is creating a new function whose meaning is a perfect combination of the two gems (i.e., there's no ‘first’ and ‘second’ really).
The following example composes a function or data transformation block that adds up the first n elements of a list. To do this, one first needs a function to extract the first n elements. In this example, this function exists in the standard library of gems, and is called take. The take gem or discrete logic visual icon is shown in FIG. 6 with textually marked input and output ports. In particular, FIG. 6 illustrates a take gem 600 with a double precision, floating point number input 602 and a list input 604. The gem 600 produces a list output at port 606. Thus, ‘take’ receives a list of ‘anythings’ and a double precision number (the number of elements to take from the list). The gem then provides a list of anythings (the list of the first n elements).
In order to add these elements, we need another gem to sum the values in the list. A sum gem can be used for this purpose. FIG. 7 is a graphical representation of the sum gem. In particular, FIG. 7 illustrates a gem 700 with a double precision input 702 and a double precision output 704. Thus, the function takes a list of double precision numbers and returns a double precision total.
In this example, the goal was to compose a function that will take the first elements of a list and then sum them. Therefore, one must attach the output of take into the input of sum. Notice that we can tell this is possible in two ways.
First, the input type of sum is a more specific type of the output of take. The type [Double] (a list of Doubles) is clearly a more specific version of [a] (the general list of ‘anythings’). So one can infer that the gems can be connected. One can say that the types are ‘unifyable’.
Second, one can actually establish the connection in the graphical environment to establish its efficacy. This is achieved by dragging a link from the output of take to the input of sum, as shown in FIG. 8. FIG. 8 illustrates the take gem 600 connected to the sum gem 700 via link 800. Under the control of the combination control module 60, as the mouse nears the input, the cursor preferably change to one of two icons, to indicate either that the connection is possible (the types are compatible), or that this connection would be illegal. In a preferred embodiment, the combination control module prevents any type of illegal connection between two gems. In this case, the types are compatible, and when the mouse button is released, the link 800 changes form (e.g., thickness or color) to indicate a valid connection.
The change in form indicates that the two gems are now bound. In fact, although the distinction between the two gems is preserved, we have in fact created a new function object and in effect there is no longer a concept of an output on take and an input on sum. Therefore, there are no types associated with these any more.
There is one more interesting point to note about the resulting graphical representation of the combination we just made. The second input to take 604 preferably changes form (e.g., shape or color) to indicate that its type has changed. In fact it has changed to the same form as the original input of sum. The combination governing module 60 recognizes that take is required to produce a list of double precision numbers as output (by being bound to sum which has this as an input requirement). This implies that it in turn must collect a list of double precision numbers (instead of any old list) in order to satisfy this requirement. It therefore advertises this fact with a change in its input type.
The foregoing discussion introduced gems (discrete logic visual icons) and combinations of gems (data transformation blocks). The following discussion more particularly describes the environment in which to select and combine gems.
As previously indicated, the logic manipulation module 56 provides a design-time environment for creating data transformation blocks 54 from an original set of visual icons 52. FIG. 9 illustrates graphical user interface 900 formed by the GUI module 58. The GUI 900 has a browser section 902 and a tabletop section 904. The browser section 902 displays gems stored in the logic repository 50. The tabletop section 904 is the working area where gems are combined. FIG. 9 illustrates an add gem 906 and a divide gem 908. The figure also illustrates a port flag 910 indicating that the output of the divide gem 908 is a double precision, floating point number. FIG. 9 also illustrates a result target 912, which constitutes the output port of the combined logic. The GUI 900 may also include execution controls 914 and a special gems pull-down window 916.
The gems are stored in one or more repositories. Preferably, they are organized categorically. Access to groups of gems can be controlled such that only selected individuals can modify them. Gems are conceptually stored in Vaults, which are ultimately some form of physical storage mechanism (like a file or database). Vaults may well have visibility and access restricted so that only certain people, groups or roles have access to them.
Inside a Vault are Drawers. Drawers are an organizing principle that categorizes gems based on overall function. For instance, there may be a drawer for the very basic gems and data types (which must always be visible) and other drawers for list manipulating gems, data access gems, and business modeling gems.
When libraries of gems are created to produce custom analyses for groups of people within the enterprise (like financial modeling for the Finance Department), these are placed into a new drawer. The new gems may be published to the target audience using enterprise security to lock the availability of the drawer (and perhaps the vault) for exclusive access to the target consumers. Drawers can also be used to separate ‘work in progress’ gems from ‘production’ gems.
A new gem is defined on the table top 904. Gems are combined to form a new function. Any input ports left unbound are treated as inputs to the newly created Gem. Once composition is complete, the new Gem is ‘defined’ by connecting the final output to the result target 912.
To compose gems together, a connection line from the output of one gem is dragged to an input of another gem (or to the target gem). FIG. 10 illustrates gems connected by this process. In this example, the add gem 1010 and divide gem 1012 from the repository are composed together to form a new function. The output of this function is connected to a result target 912 that identifies this composition as being a new Gem. Notice that the subtract Gem 1014 plays no part in the add-divide composition and is therefore not part of the gem under construction. This iconic form of programming is very simple. Therefore, the invention allows large numbers of individuals in an organization to generate logical analyses of data.
When the output of the composition is attached to the result target 912 the logic manipulation module 56 identifies that the new gem is available for testing and the ‘play’ button 1016 is illuminated on the toolbar. At this point, the user may test the gem or name the gem and save it to a vault.
As shown in FIG. 11, the logic manipulation module 56 preferably provides a feature that facilitates the gem construction process. In particular, placing a mouse pointer over a gem connector (input or output) preferably causes a window to be displayed. The displayed window lists gems that can be legally connected to the specified connector. For example, the window can suggest connections to other gems already on the table top. The window can also list gems that can be brought out onto the table top.
FIG. 11 shows that the user has let the mouse pointer hover over the output of the first (addInt) gem 1100. The program responds by showing that legal connections can be made to both the inputs of the second addInt gem 1102, or to a list of gems not yet on the table top. The list of gems is shown in window 1104. At this point, the user can click on a gem in the pop-up list 1104 to load a gem onto the table top and automatically connect it to the output of addInt gem 100. Alternately, the user can click on one of the indicated inputs to the second addInt gem 102 to form a connection to that gem. If the user moves the mouse away from the pop-up list 1104, the list is preferably closed in order to provide better visibility.
The combination control module 60 observes the type rules of the invention and suggests valid connections based upon compatible types. An example of this is shown in FIG. 12. FIG. 12 illustrates the gems on the table top that can be connected to the output of the sum gem 1200. The sum gem's output is actually typed as a ‘number’ (typeclass Num) which includes both integers (type Int) and floating point numbers (type Double). In this example, the combination control module 60 determines that both the addInt gem 1202 (taking Ints) and the log gem (taking a Double) can both be legally connected to the output of sum gem 1200. The form of the drawn line (e.g., its color or shape) can be presented to indicate that the connections are compatible, but not the same type.
Once a new gem has been defined (connected to a result target), the new gem is generally available for testing. Testing can be initiated by activating the ‘play’ button 1016 on the control panel. The test module 68 is then invoked and solicits the user for inputs to be used during testing. As shown in FIG. 13, three value editors 1300A, 1300B, and 1300C appear to collect values of the unbound inputs of the new gem. In each case, the required type of the input values is a double precision floating point number. To indicate this, the entry panels preferably display an icon 1302 that hints at the appropriate type.
The user can supply values in each panel for the respective argument. In the case of multiple values, each value may be separated with a comma. Alternately, additional windows may be presented to enter the multiple values. All input values are validated to ensure they are legal for the required type. Once the right values have been entered, the user can run or step the gem execution by using the ‘play’ button 1016.
Once argument values have been assigned the gem is executed to produce a result. The result value may be of a simple type (like a single numeric value), or it could be a data structure, such as a list. In each case, the result can be explored in the result window, which may be in the form of a pop-up window 1304. If the result is of a compound type, then the result can be explored by clicking on the ellipsis button 1306. Doing so expands the result to show more internal structure, for example a list value will expand into a scrollable list control showing all the list members, exactly as per the value entry example just examined.
Constant input values are defined using a constant gem, sometimes referred to herein as a “blue stone”. A constant gem has a specific type and value. The constant gem can be connected to a compatible input of a gem to bind this value to the gem.
Constant gems are used to ‘de-generalize’ a gem, fixing it to deal with a reduced (or specific) set of cases. For example, a filter gem can be fixed to only look for values above 1000, rather than values above any input. Attaching a constant gem to an input removes that input from the set of inputs that will be exposed by the gem under construction when it is saved.
Constant gems use the value entry panels to collect the constant values of the particular type that is asserted by the stone. For example, if the constant gem is set up to be a constant list of floating point numbers, then the list entry panel is used for elements of ‘Double’ type.
The constant gem contains a value entry panel, just like the panels that pop up when a value is required to test a gem. All constant gems really achieve is to make a value into a part of the gem definition, rather than leaving the gem to collect the value when executed.
Initially a constant gem does not know what type of value it is supposed to be representing. FIG. 14 illustrates a selected constant gem 1400. The type icon and value field showing a question mark indicates uncertainty with respect to type value. Therefore, a type is selected using pull down window 1402.
Another form of specialized gem used in accordance with an embodiment of the invention is referred to as a code gem or a green stone. Code gems are used to inject a specific expression into the gem under construction. More particularly, code gems are code editors for the analytic language that underlies features of the invention. A code gem can therefore be made to represent any user-defined function, including complex functions involving local variables and calls to external functions (in the visible set of Vaults).
The code gem allows one to access the benefits of an underlying language, while still being protected to a large extent from having to understand every nuance of the language. As shown below, in most uses the code gem feels like it is a place to enter simple expressions. However, much more is transpiring. The meaning of the code is dynamically inferred to ensure type correctness and guarantee that the resulting gem is usable and presents the right connectors to the attached gems.
Green stones are functions. To visually represent their status as functions, in one embodiment, they appear as triangular gems on the table top. By way of example, we will consider a customized filter gem to find all list entries with a value greater than 1000.
Initially, the filter gem is selected from the repository. The output of the filter gem is attached to the result target. FIG. 15 illustrates a filter gem 1500 connected to result target 912.
Pressing the code button 1502 on the toolbar adds a code gem. Technically speaking, we will be creating a lambda expression, which means an anonymous function. Notice that the code gem 1502 of FIG. 15 appears broken. The cracks on its surface are an indication that the gem requires some attention to be useable.
By default, when selecting a code gem, an editor 1600 is presented, as shown in FIG. 16. The editor initially associates itself with the code gem 1502 by name and by proximity.
In this example, the function to be described is a test for a value (which will be our list element) being greater than 1000. This code can be expressed as:
element>1000
This code is typed into the editor 1600. The entered code is checked for syntactical correctness according to a predetermined language specification, as discussed below.
FIG. 16 illustrates that various fields appear or change on the editor 1600 to indicate the meaning of the typed expression. First, an item 1602 appears in a panel to the left of the typing area. This indicates that the name “element” has been inferred to be an argument. It also indicates that the type of this argument is inferred as a ‘Num’ (a number). Num is actually a typeclass and represents either an integer (Int) or a floating point value (Double).
At the bottom of the editor 1600, is the text “->Bool”, indicated by marker 1604. This indicates that the output type of the function has been inferred to be a boolean type. Along with the argument, one can observe that a function has been produced to take a Num and produce a Bool. The type expression of this would be:((Num a=>a)->Bool). This is perfectly compatible with the required type (a->Bool); thus, a required predicate function has been created.
Observe that the system attempts to be as general as possible. In the absence of any information to the contrary, the functional language processor 74 of the execution module 70 infers that the most general type that the code will deal with is a number. If we were to force a more specific interpretation by changing the 1000 to 1000.0 (making the number into a definite floating point Double), we would see the type of element change to Double.
Syntax highlighting of the expression text itself gives further visual feedback about how the expression has been interpreted. The fact that the expression has been interpreted in a satisfactory manner is further evidenced by the icon 1502, which no longer has a cracked configuration.
Suppose we wish to construct a gem which will filter the content of a list of numeric values such that a resultant list will contain only those values in the original list which are greater than 1000. In order to do this, we can call upon the services of the filter gem in the standard library, which will take a list of any type and filter the elements in that list according to a supplied predicate function. A predicate function produces a boolean value (true or false) based on an input. In this case, a single element is examined in the original list and is ascribed a value of ‘true’ if this element should be present in the resultant list or ‘false’ otherwise.
The predicate function we want is very simple (just a test for being greater than 1000). A standard library greaterThan gem can be selected. The greaterThan gem takes two values belonging to the class ‘Orderable’ and produces a boolean value.
One can produce a function that will always test for a value being greater than 1000 by attaching a constant value of 1000 to the second argument of greaterThan. FIG. 17 shows a greaterThan gem 1700 attached to a constant gem 1702. The constant gem 1702 is configured as a floating point number with a value of ‘1000’.
FIG. 17 also illustrates a filter gem 1704. The output of our ‘greaterThan 1000’ composite function is a boolean value, but the first input to the filter gem 1704 takes a value and returns a boolean. This implies that we can't take the output of this predicate composite and simply connect it into the filter gem 1704. Actually, this makes perfect sense too, what we actually want is for the whole predicate function to be internally provided with values from the elements of the input list to filter. So, actually, we don't want to externally provide the argument to compare to 1000 at all.
The way to achieve this is by ‘input burning’, which is performed by the burn module 62. By burning the first argument to the greaterThan gem 1700 one indicates that the gem does not have a single input value. The burning operation of the invention indicates that more than one value will be provided and that this value should be collected when the function is applied to data. We want to create a functional result from the combination of the greaterThan gem 1700 and the constant 1000 supplied in the constant gem 1702. The burn operation may be performed by double clicking on the input to be burned or by some other technique. Preferably, this results in some form of visual alteration in the connection (e.g., the change in size, shape or color of a line or a visual icon, such as a fire).
Once this operation is performed, the output type of the combination is changed to a functional result (a function that takes a floating point number and returns a boolean). This is what is needed for the predicate function for filter. Because this is not a type match for the first argument of the filter function, the ‘greaterThan 1000’ combination can now be connected to the first argument of filter.
In many cases the mechanics of manually burning the inputs are unnecessary. Because complete and correct type information is always known for gem components, there are many occasions where burning is required, but in many instances the correct input burn combination can be unambiguously inferred by the burn module 62. Thus, the burn module 62 automatically links selected outputs and inputs of different gems when certain predetermined type conditions are satisfied.
In cases where the software is not able to unambiguously establish a connection in this way through burning, it will indicate that a connection is still possible if the user can determine the burn configuration needed prior to connecting. Preferably, the burn module 62 provides a popup window to identify gems that can be connected to a specific input port.
The foregoing technical description identifies a number of important features of the invention. First, the invention provides an icon based programming mechanism. Since the icons obviate the need for writing executable code, a larger group of individuals are in a position to define data processing tasks. The data transformation blocks that are formed during this process may be stored and reused. In addition, these data transformation blocks may be combined with other data transformation blocks and icons to form additional logic operations. These icons or data transformation blocks are easily shared throughout an organization, thereby facilitating consistent data processing operations throughout the organization.
Features, such as the combination control module 60, the burn module 62, and the entry panel module 66 further simplify the programming process. In particular, the combination control module 60 insures that legal operations are being performed at run time, not at a subsequent execution time. Thus, the invention creates a convergence between the development and execution environments where the programmer is constantly assured that valid operations are being proposed. The burn module 62 automatically establishes connections when possible, further simplifying the programmer's task. The value entry panels provide an intuitive interface for delivering data to the data transformation block. The invention is also advantageous in that it facilitates parallel processing in a networked environment.
The benefits of the invention are largely predicated on the underlying functional language source code associated with each icon or data transformation block. Therefore, attention turns to a more complete description of this functional language. The following description of the functional language will more fully illuminate the benefits of the invention.
Underpinning the gems of the invention is a functional computer language and a special runtime for code written in this language. During execution of the functional language expressions are decomposed automatically and can be passed to other runtime environments in order to run parts of a program in parallel. This has a huge potential upside in terms of scalability, but there's also the less obvious benefit of being able to move code to the data, instead of always bringing data to the code. This feature can be called ‘automatic pushdown’ calculating.
When a gem is to be executed, it pre-loads any argument data into the runtime and then asks the runtime to invoke a named gem by passing it an address referring to the gem. The runtime may not have the gem loaded, so it may have to fetch the gem into memory.
Once the gem is loaded, the runtime begins executing it, and this may require loading other dependent gems in the same way. The runtime may choose to split the processing of the gems it needs to run by passing some of the processing to other agents. This all happens completely transparently from the point of view of the component requesting the original gem execution. The distributed processing module 72 coordinates this operation.
Eventually, a point is reached where the gem is fully evaluated (this is usually when an actual result value becomes available). At this point, the calling component is informed that the processing is complete and can collect the result data.
Type descriptions are fairly straightforward to decode. They describe a type in a concise textual form. For functions, type descriptions deal with describing the ‘type contract’ of the function, and this can be broken down into types for each input and output. First consider the types of some simple values:
Type Description Meaning
a A type variable, meaning ‘any type’
Double A double precision floating point number
Char A character
Bool A boolean value
These types are referred to as ‘scalar’ types since they characterize a single discrete value. Type variables are very powerful as they allow one to describe whole groups of types where one can assume that all the type variables with the same letter can be replaced with any type description (but the same one for a given letter).
Other types that may be used in accordance with the invention include abstract types:
Type Description Meaning
[a] A list of values. Every value is of type ‘a’
(a, b) A pair of values. The first value is of type ‘a’, the
second value is of type ‘b’
These elements will often have their type variables set to specific types. For instance, a list of characters (a string) will be [Char], and a pair of floating point values would be (Double, Double).
Types can include type class constraints. A type class is a type subset for which all members are types and conform to having certain functions defined over them. For example, the Num type class has members Int and Double and has all the simple arithmetic functions defined. Thus, addition, subtraction and other arithmetic can be performed on both Ints and Doubles. By using the Num typeclass we can provide a single definition of add, and implement versions of it which work on Ints and Doubles to adhere to the ‘contract’ of membership of the Num typeclass for both Int and Double. Thus, a single data transformation block can be used with multiple data types. This feature of the invention significantly reduces the overall number of icons that need to be stored in the repository.
Here are some examples of type class constrained type descriptions:
Type Description Meaning
Num a => a A value which conforms to being a ‘Num’ (number).
The member types of Num are Int and Double,
meaning that ‘a’ can either be an Int or a Double.
Ord a => a All the ‘a’ type must conform to being an ordinal
type, meaning one that supports ordering functions.
User defined types (and types for which there are no special syntactic treatments) are described in type descriptions by their type names. Here are some examples:
Type Description Meaning
Tree a A tree type (from the standard Prelude). The tree
will hold values of type ‘a’
Ordering An enumeration of comparators
Finally, functions are described by their type descriptions enclosed in parentheses. Here are some examples:
Type Description Meaning
(Int −> Int −> Int) A function which takes an integer, then another
integer and produces an integer
([Char] −> Int −> Char) A function which takes a list of characters, then
an integer and produces a character
(Ord a => a −> a −> a) A function which takes two ordinal values and
returns an ordinal value
The foregoing can constitute a full list of ingredients for type expressions. Now let us turn to some examples.
Type Description Meaning
((a −> Bool) −> [a] −> A function which takes another function (which
[a]) takes any type and returns a boolean) and a list
of any type, and which returns a list of any
type. All the ‘any types’ must be the
same when this type is used.
([Char] −> Int −> Char) A function which takes a list of characters,
then an integer and produces a character
((a −> b) −> [a] −> [b]) A function which takes another function (which
takes one ‘any type’ and returns another ‘any
type’) and a list of any type, and which returns
a list of any type. Notice that in this case,
whatever type the first argument of the
provided function is must be the same type
as the elements of the list in the second
argument. Also, whatever type the second
argument of the provided function is must be
the same type as the elements of the returned
list.
((Ord a, Eq b) => A function which takes a pair of values, being a
(a, b) −> [a] −> b)) type which is a member of the typeclass Ord
and a type which is a member of the typeclass
Eq. The function also takes a list of values of
the first type the same as for the first value
in the pair. The function returns a value typed
the same as the second value in the pair.
The design emphasis of the functional language is on simplicity and a very close affinity with the nature of the runtime environment. Attention is initially directed toward distinctive aspects of the language. Subsequently, a more formal description of the language is provided.
The functional language preferably has very few keywords and constructs, and very little specialized syntax. The functional language emphasizes the definition of the problem rather than the list of steps the computer must perform to solve the problem. A language whose code resembles a formal declaration of a problem is known as a declarative language. Such languages are usually much more succinct, and being much closer to a formal definition, they provide greater confidence in the correctness of the resulting program.
The following syntactic elements characterize the functional language of the invention. First, the language uses functional language and definitions. That is, a program is essentially a collection of function definitions.
The functional language has data constructors. Data structures are formed with data constructors. Data constructors collect a series of values and build them into an abstract data structure.
The functional language also has data declarations. Data declarations are used to extend data types on which functions will operate. Each time a new data type is described, the data constructors necessary to build the data structure are also defined.
The functional language also provides a module system to organize groups of related declarations. All declarations exist in a module and their names are qualified by the module name to refer to them from outside their module.
Finally, the functional language of the invention includes type class definitions. Type classes are sets of types that have a contract defining what functions are guaranteed to operate over all member types of the set.
Having introduced these characteristics of the language of the invention, attention now turns to a more detailed discussion of each of these characteristics. Initially, attention is directed toward function declarations and definitions.
Mathematically, a function is something that maps one set onto another set. The following is an example:
• divide a b=a/b;
This is a function to divide two numbers together. The function definition begins with the name of the function. This must begin with a lower case letter, and can then be composed of letters (upper or lowercase), numbers and the underscore character (_).
After the function name comes the argument list. This is a list of argument names that will be used within the body to describe the meaning of the function. An equal sign signifies the end of the argument list and the beginning of the function's body.
The function body (or expression) describes the meaning of the function. It's important to start thinking about this part being a declaration of the meaning, rather than a list of things to do (which is the way you generally think about the definitions of functions and procedures in imperative languages like BASIC and C). In this example, we are using the ‘/’ operator (which is the name of the built-in division operation) to define this function in terms of the division of a and b. Finally, the function definition is ended with a semicolon.
Here are some other examples of function definitions:
• --recip: Calculate a reciprical
• recip x=1/x;
• --pi: An approximation of pi
• pi=3.141592;
• --second: Take the value of the second argument
• second a b=b;
In the above examples, a line comment is included. A line comment is text starting with two hyphen characters (--) and terminating at the end of the text line. Like any computer language, comments are used to amplify the meaning of the code where this is necessary to describe the intention of the programmer and to highlight special cases, limitations, choices or algorithms.
Notice how the pi function does not take any arguments, so it has an empty argument list. Also, note that we don't have to use all the arguments in the argument list in the function body expression. It is acceptable to ignore declared arguments in the definition, although it is not often that this is meaningfully used as part of the function definition.
In order to write useful functions, we have to be able to express conditions in the definition and employ other function applications as part of the function's definition. To apply a function, we simply invoke the required function by name, followed by values for the arguments. The compiler (e.g., the functional language processor 74) assumes that any list of objects directly after a function name identifies the arguments of the function application. This means one can write an application of the divide function like this:
• divide 12.0 4.0
However, if we wish to use a sub-expression in the application, parentheses are required:
• divide (20.0−8.0) (2.0+2.0)
• divide (second 20.0 12.0) (2.0+2.0)
In the last example we used an application of the second function in the application of the divide function.
In accordance with the invention, condition syntax is just another function. For convenience however the language adds a bit of syntax to help make things a little clearer (and more like other languages). The term if takes three arguments: the condition, the expression yielding the result if the condition is true, and the expression for when the condition is false. Unlike other functions, the keywords then and else are used to separate the three expressions.
Here are some examples of if with some accompanying notes:
• divide_without_error a b=if b !=0 then divide a b else 0;
Ignoring the appropriateness of suppressing a divide by zero error in this way, this function checks if the divisor is 0 and returns 0 if this is true, otherwise it performs the division. Another example function is:
• abs x=if x>=0 then x else negate x;
The absolute value of x is x itself if x is positive (or 0), otherwise the value of abs x is negate x, where this is a standard function designed to switch the sign of a value.
The functional language of the invention also supports recursion. Recursion is the technique of a function calling itself as part of its definition. Many functions have a natural sequence where the value of the function for a given input value is related to the value of the function where the argument is one less (or more). You can think of this as defining a table of values of the function for different inputs, where the function is defined in terms of the previous line in the table.
An example of recursion is a function that will calculate the factorial of a number. The factorial of a number is the product of all the counting numbers up to (and including) the number itself. A factorial table follows.
Input (n) Result (factorial n)
1 1
2 2
3 6
4 24
5 120
To create this table, we started with the input 1. A factorial involves multiplying the counting numbers up to the input number. The number one is the base case, as it is the simplest form of factorial. The result is 1 (1 multiplied by nothing else is just 1). After this, we can see that for each new line in the table, we take the result from the line before and multiply it by this input. Thus, the factorial of 3 is the factorial of 2 multiplied by 3.
Knowing the base case and the rule for succession from this case, we can now define a factorial function:
• base case:factorial 1=1
• otherwise:factorial n=n*factorial (n−1)
Finally we can turn this into a functional language function. We use if to choose between the base case and the succession case, and then just use the right hand side of the case expressions identified above:
• factorial n=if n<2 then 1 else n*factorial (n−1);
So far we've dealt with function definitions, and in simple cases this is all you need to write usable functions. However, a strictly typed language is used and all functions have an associated type that describes the types of arguments and the output of the function. This acts as a kind of ‘contract’ for the function and is used to check that the function is being applied correctly in the rest of the code. Actually, the type system infers the type expression for a function if the type declaration is missing. However, it is still good form to provide this as it specifies what the programmer intended and it provides more information for users of the function. A type declaration is also required if the programmer wishes to make a function more specific than it ordinarily would be inferred to be.
A function type declaration can occur anywhere in the same code source as the function definition (e.g., file). Here's an example for the factorial function:
• factorial::Int->int;
The only part of this that is truly significant is the type expression piece. For the time being we can assume that this is constructed from the type names of all the inputs and outputs, separated by the arrow symbol (composed of a hyphen and greater-than character). In the case of factorial, we are saying that the function takes an ‘Int’ and returns an ‘Int’. ‘Int’ is the basic integer type.
Typically we would place the declaration just before the definition. Here's an example with the divide function we saw earlier:
• --divide takes two numbers and divides a by b (a/b)
• divide::Double->Double->Double;
• divide a b=a/b;
Notice again how the type names for the arguments and the return value are separated by the arrow symbol in the type expression. You may think that separating the arguments with an arrow in this way is counter-intuitive, but we'll see later that there is good reason for this.
Another attribute of the functional language of the invention is the use of data constructors. In order to build instances of more complex data types out of simpler values, data constructors are used. These are defined in data declarations, as discussed below, and have names beginning with a capital letter. To create an instance of the data type to which they refer, you invoke a constructor (which also begins with a capital) with whatever arguments it requires as ‘parts’ of the data type to be constructed. Some critical types are treated specially, which provides a more natural syntax for creating data of the type, rather than using a named constructor. These include the list types, the character type, the string type (list of characters) and tuple types.
Assume the type Pair is defined as a set of two values. It follows that the constructor for a Pair should collect the two values to create an instance of a Pair. Thus, this is reflected in the syntax:
• . . . Pair 1.0 2 . . .
Putting this into a real context, consider what a function would look like to create a Pair from a given Int value and its factorial:
• --A function to create a Pair of a value and its factorial.
• valFacPair::Int->Pair;
• valFacPair n=Pair n (factorial n);
The main points to notice are the type expression for valFacPair, which describes the function as taking an Int (integer) value and returning a Pair. Also, in the function definition, the Pair constructor is used to collect the value ‘n’ and the factorial for this value into a new Pair instance.
Many types have multiple constructors that you can use to create values of the type. As observed in connection with data declarations, the normal definition of a Tree (binary tree abstract data type) describes two constructors: Leaf for the end points and Branch for a non-terminal point. These have different arguments, with a Leaf requiring a value to hold the node data, and a Branch requiring two Tree arguments of a given type (it defines how the tree splits into two branches).
Another simple example is the built-in type Bool. This is the type for boolean values, and accordingly it has two constructors: True and False. Neither of these require any arguments, the use of the constructor itself is enough to provide the two possible values of Bool. Note also that Bool is a very simple enumeration type, providing for 2 legal values of the type. Here is an example of a function that always returns the true value:
• alwaysTrue::Bool; --declare alwaysTrue to return the Bool type
• alwaysTrue=True; --create a True boolean value
The functional language deals with strings, tuples and lists in a special way, providing syntax for constructing values of these types in more convenient ways than using the regular constructor syntax. We'll take these in turn and learn about how to create and manipulate these types.
Lists are arbitrary length chains of values. They are considered to have a ‘head’ (the first element) and a ‘tail’ (the rest of the list). Most list manipulation is based on this principle. All the values (elements) of a list must be the same type, but this can be any data type so lists of tuples are common. The syntax for creating a list uses square brackets:
• . . . [1,2,3] . . .
The language of the invention also provides convenient syntax for describing the head:tail split. Adding a new element to the front (head) of another list can create a new list. To do this, a colon is inserted between the values for the head and tail of the list. Here are a couple of examples:
• . . . 1:[2,3] . . .
• . . . myValue:myList . . .
Characters are created using single-quotes around the character representation. This is very similar to other languages:
• . . . ‘A’ . . .
Strings are treated as lists of characters. Using double-quote-delimited character sequences can create them. Once created, the string can be manipulated like a list (with any of the list functions) and used in list constructors. Here's a straightforward example of creating a string:
• . . . “hello” . . .
Tuples are collections of (possibly differently typed) values. They are roughly analogous to structure or record types in other languages. Tuples can be created using parentheses around the required data elements. The simplest ‘sensible’ tuple is the pair. Although we earlier described a situation with a user-defined Pair type, this is actually built in as type of tuple (the 2-tuple). A pair using the built-in type can be created as:
• . . . (1.0, 2) . . .
Other tuple types are written in the same way, with different numbers of elements for a 3-tuple (triple), 4-tuple etc. For example, a 4-tuple might be constructed thus:
• . . . (1, 2.0, “three”, [‘f’,‘o’,‘u’,‘r’]) . . .
Sooner or later in any strictly typed language, you have to be able to define new types of data. A strictly typed language requires that all data be typed so that proper checking can be performed in the compiler. The compiler ensures that the program behaves correctly and as intended by the programmer. The basic trade-off is that the programmer is forced to be more specific about what types of data are stored and processed in return for the compiler being much better able to indicate when the program does not make sense. In large programs or developments with multiple programmers this is an extremely valuable service.
The language of the invention provides quite a few data types that are either built-in, or are declared in the standard library (known as the Prelude), which is usually included before any other libraries or user code is compiled.
To define a new data type, a data declaration is used. This will define the new type and describe the type in terms of constructors and type variables. This is illustrated by looking at a type declaration from the Prelude:
• data Bool=False|True;
This declares a new data type called Bool, which is either False or True. False and True are the constructors for the new Bool type. In this case, these two constructors do not require any type of parameter. The vertical bar separates the two alternatives. This sort of type is also known as an enumeration.
The language of the invention has a parametric type system, which means that you can define types that are actually whole families of types. In other words you can define types that are types of something. For example, to define trees of things, we can define the following Tree type:
• data Tree a=Leaf a|Branch (Tree a) (Tree a);
Translated into English this says: a Tree of a's is either a Leaf constructed out of an a, or a Branch constructed out of two Trees of a's.
When we come to use this Tree type, we will use one of the defined constructors for the type (either Leaf or Branch) and we will provide a parameter for the type variable ‘a’. Whatever is provided for a will set the type of the Tree and this in turn will fix how we use the Tree in other expressions. So, if we create a new Tree with the expression:
• . . . Leaf 12.3 . . .
we will end up with a Tree of floating point numbers (which could be written Tree Double). The type variable a is instantiated now and this means that we will only be able to use this instance of a Tree in other expressions dealing with Trees of Doubles.
• This means that:
• . . . Branch (Leaf 12.3) (Leaf 0.0) . . .
is legal, but:
• . . . Branch (Leaf 12.3) (Leaf “my leaf”) . . .
is not as we are mixing types (the a type variable stands for a different type in the two parameters of the Branch constructor).
To create structures (or records as they are called in some languages), we simply create lists of the types we wish to build into the structure. These sorts of types are called products.
We can even mix products and enumerations. Relying on the last example, there is a definition of Shape that can be either a Circle or a Rectangle. Having two alternative constructors provides this choice. To define the Circle, we have to provide a radius and to define a Rectangle we have to define a width and height. This is described by having each constructor take type parameters to collect the appropriate data. Circle and Rectangle are thus products of their constituent types. Here is the code:
• data Shape=Circle Double|Rectangle Double Double;
• Comments to annotate data declarations may look like this:
• data Shape=Circle Double| --radius of circle
• Rectangle Double Double; --width, height
We'll deal with data declarations in more detail later. For now, we'll move onto the final major component of the functional language of the invention, modules.
In order to write big programs, and in order to categorize core functions into libraries, a programming language needs a way to allow programmers to structure code into named ‘packages’. In the functional language used in accordance with the present invention, these are called modules.
Modules are simply an extension to the namespace for functions and data declarations which allows you to give a long (or fully qualified) name to entities. Top level identifiers therefore break down into two parts:
<module name>.<entity name>
for instance:
• statistics.mean
would be a mean function in the statistics module.
When the language is being compiled from a file or other source code storage, the module keyword changes the module into which subsequent functions and data declarations will be compiled. The names of these entities are then effectively prefixed with the module name and stored in the module: module Prelude;.
Modules define a context (or scope) for definitions. One of the nice features they provide is a way to hide definitions for use within a module (like utility functions and building blocks for the ‘real’ top-level functions). The invention allows one to specify whether a declaration is visible outside of the module in which it is defined by using the keywords public and private. A public definition is visible outside of the source module, whereas a private definition is not. If an entity is not declared to be public then it is implicitly private to its module.
In order to access public declarations from another module, an input statement must be present before the use of declarations foreign to the module using them: import Prelude;. Providing the use of a name is unambiguous, an entity (function, data declaration, etc.) can be referred to without qualifying it with the source module name. If this would result in ambiguity however, then the qualified name must be used to avoid a compiler error. If a locally defined entity has the same name as one imported from another module, then using the unqualified name will refer to the local entity, and a qualified name is the only way to refer to the imported entity.
Type classes are named sets of types for which a guarantee is made about the availability of functions to perform certain actions for all member types. Having such an abstract grouping of types is very powerful as it allows functions to declare that they will work on the type class and therefore on all member types this infers. A simple example of this is the type class Ord (orderable). It defines a set of comparator functions (such as the standard <, >, >=) which will be made available for all types which are members of it. It is possible (and very desirable) for many types to have a way to compare values of themselves. For instance, to write real programs, we have to be able to compare number values, we also would like to lexicographically compare strings and characters. So, what we do is make sure that the Org class defines all the comparator functions, and make all the types (Int, Double, Char, string etc) members of the Ord type class. Part of declaring a type as a member of a type class involves nominating functions that will perform the operations defined in the type class for values to the member type. This work is done by the instance declaration.
The upshot of this work is that one can use the ‘generic’ comparator functions defined over Ord for any of the types that are instances of Org (members of it). This makes the code much cleaner and more readable, and is a huge service to the programmer who no longer needs to locate an appropriate function to compare each specific type (greaterThanInt, greaterThanDouble etc.). Furthermore, this allows the language to share the most intuitive syntax (like operator symbols >, >=, <) across all of the types in the Ord typeclass without sacrificing any type checking.
Attention now turns to a more detailed look at the functional language of the invention. In particular, attention is directed toward consideration of more advanced features of the language.
Even though the language can claim to have ‘more advanced’ features, it is really a very simple language from most points of view. Fundamentally, the language is a set of declarations of expressions that get compiled. At runtime, the evaluator works out how to reduce this set from a particular entry point (like the main function) to the simplest form possible. Often, this ‘simplest form’, or result, is a single value, but it can be an abstract data type, or perhaps still a function. Basically, the job of the runtime is to ‘boil’ the starting expression down to its bare bones by repeatedly using the other function definitions to replace and reduce the current expression. This process stops when the runtime can find no way of further reducing the program.
So, a gem (e.g., a discrete logic visual icon or a data transformation block) is essentially a set of expressions. There's the starting point expression and a set of dependent expressions out of which we have derived this starting point.
An expression is a mathematical term meaning a formalism that describes an entity in terms of a combination of other entities. Most computer languages have syntax for expressions in order to describe arithmetic operations. However, most languages also provide mechanisms and syntax to describe the movement of state in memory (usually through data structure ‘proxies’). In these languages, a program works by starting at some entry point and executing a set of commands or instructions one at a time until some sort of ‘halt’ instruction is met. In these languages (called imperative languages because each instruction must be executed fully as the program proceeds), expressions are merely the vehicle to describe the transformation of values to create new values. In order words, they create and modify the states of the program. The control of the program ‘flow’ is directed by special instructions and, within this, expressions perform the transformations in the state.
The functional language of the invention omits the ‘flow of control’ instructions, and does away with notions of global or persistent state. Instead, a program is ‘declared’ purely in terms of abstractions. Because of this, functional languages have what is known as a declarative syntax. Moreover, the expressions used have extra meaning as functions. Functions map a set onto another set, and for any given input to a specific function, the output will always be the same. This fact can be exploited by a functional language runtime, so that the expression defining a function is never evaluated more than once for given set inputs. This is known as memoisation.
By splitting the program up into a set of functions, we obtain the granularity required to perform the memoisation optimization as described above, and also the granularity required to write ‘real’ programs.
We'll now look at features of the language more fully and learn where expressions can be written. The main site for an expression is the function body. The function body can consist simply of a basic expression, or of some of the following types of special expression. One type of special expression is a constructor, which builds a more abstract data type from a set of simpler types. Another type of special expression is a LET expression, which is used to define local variables and functions. A SWITCH expression is used to switch between sub-expressions based on a value or pattern. A LAMDA expression is an unnamed function definition.
Each of the special expressions and their syntax will be dealt with in subsequent sections that will discuss the features they provide. In this section we'll continue to talk about the basic expression syntax.
Basic expressions describe a calculation, and hence a resultant value derived from a set of variables, arguments and constants, in terms of functions and built-in operations.
Local variables can be used in a function where this is convenient to express an intermediate result. The syntax to define a local variable is the LET expression. The form of the LET expression is:
• Let
• a=12;
• b=sin 90.0;
• in
• a*b;
Note that as an expression, the LET block takes on the value of its enclosing expression. Also, the scope of the variables defined in the head of the LET is limited to the expression (i.e. the LET is the enclosing scope).
LET expressions can be nested to arbitrary depth. This allows for the scope of defined variables to be structured appropriately and to add clarity to the overall expression.
Note that the use of local variables is probably a little different than what one might expect if coming from an imperative language background. Local variables are immutable once set in the head of the LET expression. You cannot reassign values to local variables in the LET body. This is in keeping with the functional programming paradigm that rules that objects do not change once they have been created, but new object instances can be made of the same type, but with different values.
Local functions, like local variables are used when it is necessary or meaningful to define a function in terms of one or more private functions. Like local variables, the LET block is used to define the functions and their enclosing scope. In fact, local functions are defined in exactly the same way as value variables. This follows because logically there is no difference between a value and a function. Here's an example of an, albeit tautological, pair of nested LET expressions containing both local variable and local function definitions:
doublePlusAndOne x y =
let
doubleIt x = x + x;
in
let
z = doubleIt x;
addTogether x y = x + y;
p = 1;
in
addTogether z y + p;
There are two points worth noting in connection with this example. First, local variable function definitions can be freely intermixed in the head of a LET expression. Next, variable hiding is possible because of the scoping rules. In the example, we reuse the variables x and y in the definitions of doubleIt and addTogether. The most local definitions are used in the application of these variables. The same applies to function names.
A switch expression is the way to choose between a set of alternative expressions depending on a pattern or value. Switch expressions are also used to access data elements in a compound data type (i.e., to ‘break apart’ a compound value into its constituent pieces).
A lambda expression is an expression that denotes an anonymous function. The name derives from the mathematical symbol used to introduce the concept of an unnamed function, which uses the Greek letter Lambda (λ).
Lambda expressions are used in Lambda Calculus, which is a calculus that permits the simplification of functional expressions using various forms of reduction. Lambda expressions are interesting in the language of the invention for several reasons. First, there are often times when there is no point giving a name to a local function. A lambda expression is more concise and doesn't require redundant naming of the function. Next, one can build a lambda expression (function) inside another function and return it.
A backslash (\) is used to introduce a lambda expression. This character is chosen because of its resemblance to the Greek letter Lambda. A lambda expression is similar to a function definition, but with a few syntactical differences derived from the mathematical notation (and to differentiate it better).
• Here is the form of a lambda expression: \xs n->length xs+n.
Let's look at a simple example of where one might use a lambda expression. Imagine we want to filter a list of double precision numbers to extract only those values which are larger than 1000. We might use the standard filter function to achieve this. This function provides all the logic for describing a subset of a list, but requires a predicate function (a function taking a list item and returning a boolean) in order to ‘pick’ which items are in the subset.
One approach to this problem might be to write a named predicate function like this:
• greaterThanAThousand item=item>1000;
and then apply this to the filter function:
• . . . filter greaterThanAThousand myOriginalList . . .
This might be the correct approach if the greaterThanAThousand function was likely to be reused. However, it's likely that its only purpose is for this application. Therefore, it is much better (not to mention more concise) to use a lambda expression:
• . . . filter (\item->item>1000) myOriginalList . . .
One of the most powerful and intriguing things about the functional programming paradigm as provided by the invention is the capability to partially evaluate a function, leaving the rest of the function to be passed elsewhere for later complete evaluation.
This is best demonstrated with an example. Consider the previously discussed filter example. To recap, we wanted to express the application of filter on a list to produce a subset of the list where all items were over 1000. Here is the code:
• . . . filter (item->item>1000) myOriginalList . . .
This code works well when we want to apply the filter function right away to our list. However, we may want to reuse this particular filter on several lists. We can use partial evaluation in to achieve this.
What we can do is partially apply the filter function by only initially supplying the predicate function:
• . . . filter (item->item>1000) . . .
Unlike most languages, which require a full set of required arguments (either provided or defaulted) to perform their task, the language of the invention allows us only to provide a subset of the arguments to filter. This will then produce another function that is unnamed, but represents the concept ‘the filter that will pick items over a thousand’. This new function will take the remaining missing arguments (in this case a list of double precision numbers) to do its work, or if there is more than one remaining argument, we could produce yet another derived function, by applying another subset of the remaining arguments.
Partial function applications can be returned from a function, be bound to a local variable, or be stored in a data structure. They can then be applied at a later time to complete their task.
In procedural languages there is a clear distinction between functions and regular values. You are often required to create pointers to functions in these languages in order to be able to manipulate the functions themselves.
In functional languages this is not the case. We can treat functions like any other expression, and in particular we can use them as arguments. No special syntax is required to do this, function parameters look exactly the same as any other kind of parameter. The only way you would know that a parameter is a function parameter is to take a look at the type of the parameter.
We'll examine an example now. Suppose we want to be able to apply any given function twice to a particular argument. We can code this operation as a function called doTwice:
• doTwice f x=f (f x);
The body of the definition applies f to x and then applies f again to the result. The type description for this function is:
• (a->a)->a->a
This reveals that the function does indeed take a function as its first parameter, the (a->a) being the pertinent part of the full type description.
Using doTwice doesn't involve any extra syntax either:
• . . . doTwice factorial 3 . . .
yields 720 as the result.
We could write a generalized version of doTwice that will apply a function a given number of times to an input value. Here's a definition of such a function:
• doMany n f x=if n==0 then x else f (doMany (n−1) f x);
As well as acting as an argument, a function can also be the result of evaluating an expression. Here's an example of a function that returns one of two functions depending on an input value:
• taxFunction income=if income>10000 then higherTaxCalc else lowerTaxCalc;
One of either the higherTaxCalc or lowerTaxCalc functions is returned depending on the value of income passed to taxFunction. These returned functions have a specific type that controls what we can do with the return of taxFunction. It's quite likely, given this example, that they would take the income and apply a banded tax calculation, returning the total tax liability. In this case, these returnable functions would have the type:
• (Double->Double)
This in turn would make the type of taxFunction:
• Double->(Double->Double)
What is even more interesting is the fact that the type system of the invention is flexible enough to permit functions as arguments and return polymorphic functions.
Now that the iconic and functional language aspects of the invention have been fully described, it is useful to more carefully consider previously introduced concepts. As previously indicated, the combination control module 60 only allows compositions that are legal and that result in unambiguous meaning. In other words, to get from state “A” of a gem to another state “B”, it must be possible to describe the meaning of “B” in a well-defined manner in the underlying functional language. In addition, the transformation A->B must be able to produce a new global typing of B that is expressible in the type language. Further, there must not be any violations of type constraints and bindings already established at A.
There are instances in which the combination control module 60 detects a supposedly “illegal” connection attempt. In many of these instances there is a simple transformation of the function that would make it legal. The logic manipulation module 56 supports “partial evaluation”. This essentially moves one or more inputs on the function being connected into its output (usually turning the output into a function rather than a straightforward value). This most frequently occurs when a function is expecting a functional input (i.e., it is a “higher order” function) and an attempt is made to connect the output of a regular gem. In this case, the burn module 62 recognizes that if it burns one or more of the inputs on the outer function, it will be able to create an entity that matches the input. When it can do this unambiguously, then the burning is done automatically. When there is more than one possibility (a set of permutations of burnt inputs), the burn module 62 indicates there is a burn configuration that would qualify the connection, but it cannot determine which is correct. Thus, the burn module 62 moves an input to the output to form a new type out of essentially the same function (by precluding a local value for that input). The burn module 62 suggests these transformations to the user in an ambiguous case and automatically implements the transformations in an unambiguous case.
Value editors 1300 or value entry panels have been described as automatically generating value input based on decomposition of type. The code for the entry panel module 66 may also be used to create the result interface 1304 when a result value is obtained. This allows the user to “drill down” into the result value and see how it is composed.
Another aspect of this automatic decomposition is that it allows new entry/result panels to be “registered” with the system. Preferably, the logic manipulation module 56 automatically spots a type match once the value has been decomposed to the right level, and it substitutes the registered panel to collect or display an abstract value rather than further deconstructing the value.
If there are several suitable panels registered (e.g., an edit panel and a slider panel for setting an integer value), then the logic manipulation module 56 can note this dichotomy. For instance, a default (e.g., edit panel) may be set and a decision may then be made to: (a) use the default, (b) select from another registered panel, or (C) substitute an entirely different panel that will deal with this type of value. This registration feature is also designed to accommodate the fact that one can declare a new type in the language.
It should now be appreciated that new data transformation blocks may be constructed solely through the use of logic icons. The use of logic icons may be supplemented or substituted by the use of a code gem 1502 and its corresponding code entry window 1600. The combination control module 60 also supervises text entry into the code entry window 1600. That is, the combination control module 60 continuously parses and interprets the contents of the entered code and provides feedback as to whether the code makes sense, the interpretation of the code in terms of inputs and output, and the data types.
The foregoing description, for purposes of explanation, used specific nomenclature to provide a through understanding of the invention. However, it will be apparent to one skilled in the art that specific details are not required in order to practice the invention. Thus, the foregoing descriptions of specific embodiments of the invention are presented for purposes of illustration and description. They are not intended to be exhaustive or to limit the invention to the precise forms disclosed; obviously, many modifications and variations are possible in view of the above teachings. The embodiments were chosen and described in order to best explain the principles of the invention and its practical applications, the thereby enable other skilled in the art to best utilize the invention and various embodiments with various modifications as are suited to the particular use contemplated. It is intended that the following claims and their equivalents define the scope of the invention.
Claims (26)
1. A method of constructing a data transformation block, comprising:
selecting a first discrete logic visual icon from a logic repository;
choosing a second discrete logic visual icon from said logic repository;
establishing a combination valid state when said first discrete logic visual icon can be combined with said second discrete logic visual icon;
combining said first discrete logic visual icon and said second discrete logic visual icon in response to said combination valid state to form a data transformation block, said data transformation block having a corresponding functional language source code description of the logical operations to be performed by said data transformation block, wherein the functional language source code description has an algebraic type system and a declarative syntax; and
storing said data transformation block in said logic repository.
2. The method of claim 1 further comprising:
selecting said data transformation block from said logic repository;
choosing a third discrete logic visual icon from said logic repository;
establishing a combination valid state when said data transformation block can be combined with said third discrete logic visual icon;
combining said data transformation block with said third discrete logic visual icon in response to said combination valid state to form a new data transformation block, said new data transformation block having a corresponding functional language source code description of the logical operations to be performed by said new data transformation block; and
storing said new data transformation block in said logic repository.
3. The method of claim 1 wherein said functional language source code description includes a first executable logic code segment corresponding to said first discrete logic visual icon and a second executable logic code segment corresponding to said second discrete logic visual icon.
4. The method of claim 3 wherein said first executable logic code segment is processed on a first computer and said second executable logic code segment is processed on a second computer.
5. The method of claim 1 further comprising applying data to said data transformation block to form transformed data.
6. The method of claim 5 further comprising displaying said transformed data.
7. The method of claim 6 further comprising supplying intermediate processing results prior to said displaying.
8. The method of claim 5 wherein said applying includes:
applying a first data type to said data transformation block to form transformed data of a first data type; and
applying a second data type to said data transformation block to form transformed data of a second data type.
9. The method of claim 1 further comprising automatically linking, under predetermined conditions, selected inputs and outputs of said first discrete logic visual icon and said second discrete logic visual icon.
10. The method of claim 1 further comprising establishing entry panel inputs to said first discrete logic visual icon and said second discrete logic visual icon.
11. The method of claim 10 wherein establishing includes selecting a constant value visual icon as an entry panel input.
12. The method of claim 1 wherein establishing includes establishing a combination valid state when type definitions for said first discrete logic visual icon match type definitions for said second discrete logic visual icon.
13. The method of claim 1 further comprising forming a new discrete logic visual icon by:
selecting a discrete logic visual icon template; and
entering into a display screen a functional language source code description of logical operations to be performed by said new discrete logic visual icon.
14. A computer readable memory to direct a computer to function in a specified manner, comprising:
a logic repository storing a set of discrete logic visual icons; and
executable instructions including
first executable instructions to selectively produce a combination valid state when a first discrete logic visual icon from said logic repository is combined with a second discrete logic visual icon from said logic repository, and
second executable instructions to combine said first discrete logic visual icon and said second discrete logic visual icon in response to said combination valid state to form a data transformation block, said data transformation block having a corresponding functional language source code description of the logical operations to be performed by said data transformation block, wherein the functional language source code description has an algebraic type system and a declarative syntax.
15. The computer readable memory of claim 14 further comprising executable instructions to combine said data transformation block with a third discrete logic visual icon to form a new data transformation block, said new data transformation block having a corresponding functional language source code description of the logical operations to be performed by said new data transformation block.
16. The computer readable memory of claim 14 wherein said functional language source code description utilizes type classes.
17. The computer readable memory of claim 14 wherein said functional language source code description processes input data to form transformed data.
18. The computer readable memory of claim 17 further comprising executable instructions to display said transformed data.
19. The computer readable memory of claim 18 further comprising executable instructions to supply intermediate processing results.
20. The computer readable memory of claim 14 wherein said functional language source code description includes a first executable logic code segment corresponding to said first discrete logic visual icon and a second executable logic code segment corresponding to said second discrete logic visual icon.
21. The computer readable memory of claim 14 wherein said data transformation block includes executable instructions to produce a first data type output in response to a first data type input and a second data type output in response to a second data type input.
22. The computer readable memory of claim 14 further comprising executable instructions to automatically link, under predetermined conditions, selected inputs and outputs of said first discrete logic visual icon and said second discrete logic visual icon.
23. The computer readable memory of claim 14 further comprising executable instructions to form entry panel inputs to said first discrete logic visual icon and said second discrete logic visual icon.
24. The computer readable memory of claim 23 further comprising executable instructions to form a constant value visual icon as an entry panel input.
25. The computer readable memory of claim 14 wherein said first executable instructions produce said combination valid state when type definitions for said first discrete logic visual icon match type definitions for said second discrete logic visual icon.
26. The computer readable memory of claim 14 further comprising executable instructions to:
generate a discrete logic visual icon template; and
produce a display screen to receive a functional language source code description of logical operations to be performed by a new discrete logic visual icon corresponding to said discrete logic visual icon template.
US10183898 2001-09-28 2002-06-25 Apparatus and method for combining discrete logic visual icons to form a data transformation block Active 2024-06-12 US7299419B2 (en)
Priority Applications (2)
Application Number Priority Date Filing Date Title
US32617601 true 2001-09-28 2001-09-28
US10183898 US7299419B2 (en) 2001-09-28 2002-06-25 Apparatus and method for combining discrete logic visual icons to form a data transformation block
Applications Claiming Priority (2)
Application Number Priority Date Filing Date Title
US10183898 US7299419B2 (en) 2001-09-28 2002-06-25 Apparatus and method for combining discrete logic visual icons to form a data transformation block
US11870392 US7900150B2 (en) 2001-09-28 2007-10-10 Apparatus and method for combining discrete logic visual icons to form a data transformation block
Publications (2)
Publication Number Publication Date
US20030071844A1 true US20030071844A1 (en) 2003-04-17
US7299419B2 true US7299419B2 (en) 2007-11-20
Family
ID=23271112
Family Applications (2)
Application Number Title Priority Date Filing Date
US10183898 Active 2024-06-12 US7299419B2 (en) 2001-09-28 2002-06-25 Apparatus and method for combining discrete logic visual icons to form a data transformation block
US11870392 Active 2023-06-24 US7900150B2 (en) 2001-09-28 2007-10-10 Apparatus and method for combining discrete logic visual icons to form a data transformation block
Family Applications After (1)
Application Number Title Priority Date Filing Date
US11870392 Active 2023-06-24 US7900150B2 (en) 2001-09-28 2007-10-10 Apparatus and method for combining discrete logic visual icons to form a data transformation block
Country Status (2)
Country Link
US (2) US7299419B2 (en)
WO (1) WO2003029967A1 (en)
Cited By (14)
* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20050171967A1 (en) * 2004-01-30 2005-08-04 Paul Yuknewicz System and method for exposing tasks in a development environment
US20070150749A1 (en) * 2005-12-22 2007-06-28 Andrew Monaghan Creating a terminal application
US20080059837A1 (en) * 2006-09-01 2008-03-06 Dematteis James M Active Block Diagram For Controlling Elements In An Electronic Device
US20080155411A1 (en) * 2006-12-11 2008-06-26 Sitecore A/S Method for ensuring internet content compliance
US20080263463A1 (en) * 2007-04-20 2008-10-23 Neumann Nicholas G Configurable Wires in a Statechart
US20080307360A1 (en) * 2007-06-08 2008-12-11 Apple Inc. Multi-Dimensional Desktop
US20080307364A1 (en) * 2007-06-08 2008-12-11 Apple Inc. Visualization object receptacle
US20080307330A1 (en) * 2007-06-08 2008-12-11 Apple Inc. Visualization object divet
US20090288065A1 (en) * 2008-05-16 2009-11-19 Microsoft Corporation Transparent Type Matching in a Programming Environment
US20110258583A1 (en) * 2007-08-06 2011-10-20 Nikon Corporation Processing execution program product and processing execution apparatus
US20120331472A1 (en) * 2011-06-27 2012-12-27 Cisco Technology, Inc. Ad hoc generation of work item entity for geospatial entity based on symbol manipulation language-based workflow item
US8380700B2 (en) * 2011-04-13 2013-02-19 Cisco Technology, Inc. Ad hoc geospatial directory of users based on optimizing non-Turing complete executable application
US8892997B2 (en) 2007-06-08 2014-11-18 Apple Inc. Overflow stack user interface
US9292478B2 (en) 2008-12-22 2016-03-22 International Business Machines Corporation Visual editor for editing complex expressions
Families Citing this family (18)
* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
GB0501730D0 (en) * 2005-01-27 2005-03-02 Microgen Plc Process
US20060229853A1 (en) * 2005-04-07 2006-10-12 Business Objects, S.A. Apparatus and method for data modeling business logic
US20060230027A1 (en) * 2005-04-07 2006-10-12 Kellet Nicholas G Apparatus and method for utilizing sentence component metadata to create database queries
US20060230028A1 (en) * 2005-04-07 2006-10-12 Business Objects, S.A. Apparatus and method for constructing complex database query statements based on business analysis comparators
US20060229866A1 (en) * 2005-04-07 2006-10-12 Business Objects, S.A. Apparatus and method for deterministically constructing a text question for application to a data source
US8046678B2 (en) * 2005-08-22 2011-10-25 Yahoo! Inc. Employing partial evaluation to provide a page
US7405593B2 (en) * 2005-10-28 2008-07-29 Fujitsu Limited Systems and methods for transmitting signals across integrated circuit chips
US7917525B2 (en) * 2005-12-06 2011-03-29 Ingenix, Inc. Analyzing administrative healthcare claims data and other data sources
CA2615161A1 (en) * 2006-12-21 2008-06-21 Aquatic Informatics Inc. Automated validation using probabilistic parity space
US7865835B2 (en) * 2007-10-25 2011-01-04 Aquatic Informatics Inc. System and method for hydrological analysis
US8074177B2 (en) * 2008-03-20 2011-12-06 National Instruments Corporation User defined wire appearance indicating data type in a graphical programming environment
US8078980B2 (en) * 2008-03-20 2011-12-13 National Instruments Corporation User defined wire appearance indicating communication functionality in a graphical programming environment
KR100980683B1 (en) * 2008-09-01 2010-09-08 삼성전자주식회사 Apparatus and method for providing user interface to generate menu list of potable terminal
US9134973B2 (en) * 2009-02-26 2015-09-15 Red Hat, Inc. Dynamic compiling and loading at runtime
US8645854B2 (en) * 2010-01-19 2014-02-04 Verizon Patent And Licensing Inc. Provisioning workflow management methods and systems
US20110320504A1 (en) * 2010-06-28 2011-12-29 International Business Machines Corporation Modeling for event enabled content management systems
JP2016521369A (en) * 2013-05-13 2016-07-21 株式会社ミツトヨ Machine vision system program editing environment that includes the copy-and-paste functionality that was conscious of the operational context
US20160188352A1 (en) * 2014-12-29 2016-06-30 Nvidia Corporation System and method for compiler support for compile time customization of code
Citations (25)
* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US4796179A (en) * 1986-08-20 1989-01-03 Integrated Systems, Inc. Multirate real time control system code generator
US5485600A (en) * 1992-11-09 1996-01-16 Virtual Prototypes, Inc. Computer modelling system and method for specifying the behavior of graphical operator interfaces
JPH1069379A (en) * 1996-08-28 1998-03-10 Yamatake Honeywell Co Ltd Graphical programing method
US5752033A (en) * 1994-05-16 1998-05-12 Mitsubishi Denki Kabushiki Kaisha Programming device for programmable controller, functional unit for programmable controller, and method of inputting memory display for programming device
US5861882A (en) * 1994-11-03 1999-01-19 Motorola, Inc. Integrated test and measurement means employing a graphical user interface
US5862379A (en) * 1995-03-07 1999-01-19 International Business Machines Corporation Visual programming tool for developing software applications
US5933637A (en) * 1993-08-23 1999-08-03 Lucent Technologies Inc. Method and apparatus for configuring computer programs from available subprograms
US6054986A (en) * 1996-09-13 2000-04-25 Yamatake-Honeywell Co., Ltd. Method for displaying functional objects in a visual program
US6064816A (en) * 1996-09-23 2000-05-16 National Instruments Corporation System and method for performing class propagation and type checking in a graphical automation client
US6151643A (en) 1996-06-07 2000-11-21 Networks Associates, Inc. Automatic updating of diverse software products on multiple client computer systems by downloading scanning application to client computer and generating software list on client computer
US6275976B1 (en) * 1996-03-15 2001-08-14 Joseph M. Scandura Automated method for building and maintaining software including methods for verifying that systems are internally consistent and correct relative to their specifications
US6282699B1 (en) 1999-02-23 2001-08-28 National Instruments Corporation Code node for a graphical programming system which invokes execution of textual code
US6334211B1 (en) 1989-09-29 2001-12-25 Hitachi, Ltd. Method for visual programming with aid of animation
US6366300B1 (en) 1997-03-11 2002-04-02 Mitsubishi Denki Kabushiki Kaisha Visual programming method and its system
US6385769B1 (en) 1999-02-03 2002-05-07 International Business Machines Corporation Text based object oriented program code with a visual program builder and parser support for predetermined and not predetermined formats
US6396517B1 (en) * 1999-03-01 2002-05-28 Agilent Technologies, Inc. Integrated trigger function display system and methodology for trigger definition development in a signal measurement system having a graphical user interface
US20020069399A1 (en) * 1999-08-16 2002-06-06 Z-Force Corporation System of reusable software parts and methods of use
US20020095653A1 (en) * 1999-03-30 2002-07-18 Shawn Parr Visual architecture software language
US6437805B1 (en) * 1996-09-23 2002-08-20 National Instruments Corporation System and method for accessing object capabilities in a graphical program
US20020196283A1 (en) * 2001-06-20 2002-12-26 Trevor Petruk System and method for creating a graphical program based on a pre-defined program process
US20030035010A1 (en) * 2001-08-14 2003-02-20 Kodosky Jeffrey L. Configuring graphical program nodes for remote execution
US20030101025A1 (en) * 2001-08-15 2003-05-29 National Instruments Corporation Generating a configuration diagram based on user specification of a task
US6760842B1 (en) * 1999-12-07 2004-07-06 International Business Machines Corporation Finite state automata security system
US20040267515A1 (en) * 2000-03-06 2004-12-30 Mcdaniel Richard Gary Programming automation by demonstration
US6922824B2 (en) * 2001-02-23 2005-07-26 Danger, Inc. System and method for transforming object code
Patent Citations (25)
* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US4796179A (en) * 1986-08-20 1989-01-03 Integrated Systems, Inc. Multirate real time control system code generator
US6334211B1 (en) 1989-09-29 2001-12-25 Hitachi, Ltd. Method for visual programming with aid of animation
US5485600A (en) * 1992-11-09 1996-01-16 Virtual Prototypes, Inc. Computer modelling system and method for specifying the behavior of graphical operator interfaces
US5933637A (en) * 1993-08-23 1999-08-03 Lucent Technologies Inc. Method and apparatus for configuring computer programs from available subprograms
US5752033A (en) * 1994-05-16 1998-05-12 Mitsubishi Denki Kabushiki Kaisha Programming device for programmable controller, functional unit for programmable controller, and method of inputting memory display for programming device
US5861882A (en) * 1994-11-03 1999-01-19 Motorola, Inc. Integrated test and measurement means employing a graphical user interface
US5862379A (en) * 1995-03-07 1999-01-19 International Business Machines Corporation Visual programming tool for developing software applications
US6275976B1 (en) * 1996-03-15 2001-08-14 Joseph M. Scandura Automated method for building and maintaining software including methods for verifying that systems are internally consistent and correct relative to their specifications
US6151643A (en) 1996-06-07 2000-11-21 Networks Associates, Inc. Automatic updating of diverse software products on multiple client computer systems by downloading scanning application to client computer and generating software list on client computer
JPH1069379A (en) * 1996-08-28 1998-03-10 Yamatake Honeywell Co Ltd Graphical programing method
US6054986A (en) * 1996-09-13 2000-04-25 Yamatake-Honeywell Co., Ltd. Method for displaying functional objects in a visual program
US6064816A (en) * 1996-09-23 2000-05-16 National Instruments Corporation System and method for performing class propagation and type checking in a graphical automation client
US6437805B1 (en) * 1996-09-23 2002-08-20 National Instruments Corporation System and method for accessing object capabilities in a graphical program
US6366300B1 (en) 1997-03-11 2002-04-02 Mitsubishi Denki Kabushiki Kaisha Visual programming method and its system
US6385769B1 (en) 1999-02-03 2002-05-07 International Business Machines Corporation Text based object oriented program code with a visual program builder and parser support for predetermined and not predetermined formats
US6282699B1 (en) 1999-02-23 2001-08-28 National Instruments Corporation Code node for a graphical programming system which invokes execution of textual code
US6396517B1 (en) * 1999-03-01 2002-05-28 Agilent Technologies, Inc. Integrated trigger function display system and methodology for trigger definition development in a signal measurement system having a graphical user interface
US20020095653A1 (en) * 1999-03-30 2002-07-18 Shawn Parr Visual architecture software language
US20020069399A1 (en) * 1999-08-16 2002-06-06 Z-Force Corporation System of reusable software parts and methods of use
US6760842B1 (en) * 1999-12-07 2004-07-06 International Business Machines Corporation Finite state automata security system
US20040267515A1 (en) * 2000-03-06 2004-12-30 Mcdaniel Richard Gary Programming automation by demonstration
US6922824B2 (en) * 2001-02-23 2005-07-26 Danger, Inc. System and method for transforming object code
US20020196283A1 (en) * 2001-06-20 2002-12-26 Trevor Petruk System and method for creating a graphical program based on a pre-defined program process
US20030035010A1 (en) * 2001-08-14 2003-02-20 Kodosky Jeffrey L. Configuring graphical program nodes for remote execution
US20030101025A1 (en) * 2001-08-15 2003-05-29 National Instruments Corporation Generating a configuration diagram based on user specification of a task
Cited By (22)
* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7490314B2 (en) * 2004-01-30 2009-02-10 Microsoft Corporation System and method for exposing tasks in a development environment
US20050171967A1 (en) * 2004-01-30 2005-08-04 Paul Yuknewicz System and method for exposing tasks in a development environment
US20070150749A1 (en) * 2005-12-22 2007-06-28 Andrew Monaghan Creating a terminal application
US8589868B2 (en) * 2005-12-22 2013-11-19 Ncr Corporation Creating a terminal application
US20080059837A1 (en) * 2006-09-01 2008-03-06 Dematteis James M Active Block Diagram For Controlling Elements In An Electronic Device
US20080155411A1 (en) * 2006-12-11 2008-06-26 Sitecore A/S Method for ensuring internet content compliance
US20080263463A1 (en) * 2007-04-20 2008-10-23 Neumann Nicholas G Configurable Wires in a Statechart
US7882445B2 (en) * 2007-04-20 2011-02-01 National Instruments Corporation Configurable wires in a statechart
US20080307330A1 (en) * 2007-06-08 2008-12-11 Apple Inc. Visualization object divet
US9086785B2 (en) 2007-06-08 2015-07-21 Apple Inc. Visualization object receptacle
US20080307364A1 (en) * 2007-06-08 2008-12-11 Apple Inc. Visualization object receptacle
US20080307360A1 (en) * 2007-06-08 2008-12-11 Apple Inc. Multi-Dimensional Desktop
US8892997B2 (en) 2007-06-08 2014-11-18 Apple Inc. Overflow stack user interface
US8745535B2 (en) 2007-06-08 2014-06-03 Apple Inc. Multi-dimensional desktop
US20110258583A1 (en) * 2007-08-06 2011-10-20 Nikon Corporation Processing execution program product and processing execution apparatus
US8745580B2 (en) * 2008-05-16 2014-06-03 Microsoft Corporation Transparent type matching in a programming environment
US20090288065A1 (en) * 2008-05-16 2009-11-19 Microsoft Corporation Transparent Type Matching in a Programming Environment
US9311278B2 (en) 2008-12-22 2016-04-12 International Business Machines Corporation Visual editor for editing complex expressions
US9292478B2 (en) 2008-12-22 2016-03-22 International Business Machines Corporation Visual editor for editing complex expressions
US8380700B2 (en) * 2011-04-13 2013-02-19 Cisco Technology, Inc. Ad hoc geospatial directory of users based on optimizing non-Turing complete executable application
US20120331472A1 (en) * 2011-06-27 2012-12-27 Cisco Technology, Inc. Ad hoc generation of work item entity for geospatial entity based on symbol manipulation language-based workflow item
US8612279B2 (en) * 2011-06-27 2013-12-17 Cisco Technology, Inc. Ad hoc generation of work item entity for geospatial entity based on symbol manipulation language-based workflow item
Also Published As
Publication number Publication date Type
WO2003029967A1 (en) 2003-04-10 application
US7900150B2 (en) 2011-03-01 grant
US20080034303A1 (en) 2008-02-07 application
US20030071844A1 (en) 2003-04-17 application
Similar Documents
Publication Publication Date Title
Garlan et al. Architectural mismatch: Why reuse is so hard
Gansner et al. An open graph visualization system and its applications to software engineering
Carlsson et al. SICStus Prolog user's manual
Ousterhout et al. Tcl and the Tk toolkit
Kazman et al. View extraction and view fusion in architectural understanding
Weinand et al. Design and implementation of ET++, a seamless object-oriented application framework
Cardelli Amber
Jackson et al. Lightweight extraction of object models from bytecode
Czarnecki et al. Feature-based survey of model transformation approaches
US7322025B2 (en) Method and apparatus for versioning and configuration management of object models
US5970490A (en) Integration platform for heterogeneous databases
US5956479A (en) Demand based generation of symbolic information
US6510551B1 (en) System for expressing complex data relationships using simple language constructs
Bąk et al. Feature and meta-models in Clafer: mixed, specialized, and coupled
US7055142B2 (en) Permutation nuances of the integration of processes and queries as processes at queues
US5758160A (en) Method and apparatus for building a software program using dependencies derived from software component interfaces
US20040267760A1 (en) Query intermediate language method and system
Kästner et al. Type checking annotation-based product lines
US20030163801A1 (en) Computer-based method for defining a patch in computer source code including conditional compilation cell groups
Syme et al. Expert F♯
US5325533A (en) Engineering system for modeling computer programs
US6904588B2 (en) Pattern-based comparison and merging of model versions
US5485618A (en) Methods and interface for building command expressions in a computer system
Chen et al. Ciao: A graphical navigator for software and document repositories
US20060074735A1 (en) Ink-enabled workflow authoring
Legal Events
Date Code Title Description
AS Assignment
Owner name: CRYSTAL DECISIONS, INC., CALIFORNIA
Free format text: ASSIGNMENT OF ASSIGNORS INTEREST;ASSIGNOR:EVANS, LUKE WILLIAM;REEL/FRAME:013057/0648
Effective date: 20020508
AS Assignment
Owner name: BUSINESS OBJECTS AMERICAS, CALIFORNIA
Free format text: MERGER;ASSIGNOR:CRYSTAL DECISIONS, INC.;REEL/FRAME:016153/0256
Effective date: 20031211
AS Assignment
Owner name: BUSINESS OBJECTS, S.A., FRANCE
Free format text: ASSIGNMENT OF ASSIGNORS INTEREST;ASSIGNOR:BUSINESS OBJECTS AMERICAS;REEL/FRAME:016195/0671
Effective date: 20050427
AS Assignment
Owner name: BUSINESS OBJECTS SOFTWARE LTD., IRELAND
Free format text: ASSIGNMENT OF ASSIGNORS INTEREST;ASSIGNOR:BUSINESS OBJECTS, S.A.;REEL/FRAME:020156/0411
Effective date: 20071031
Owner name: BUSINESS OBJECTS SOFTWARE LTD.,IRELAND
Free format text: ASSIGNMENT OF ASSIGNORS INTEREST;ASSIGNOR:BUSINESS OBJECTS, S.A.;REEL/FRAME:020156/0411
Effective date: 20071031
FPAY Fee payment
Year of fee payment: 4
FPAY Fee payment
Year of fee payment: 8
|
__label__pos
| 0.644311 |
package main import ( "encoding/json" "fmt" "io/ioutil" "log" "os" "os/exec" "path/filepath" "regexp" "runtime" "runtime/debug" "time" "git.sequentialread.com/forest/greenhouse/pki" errors "git.sequentialread.com/forest/pkg-errors" ) type Config struct { FrontendPort int FrontendDomain string FrontendTLSCertificate string FrontendTLSKey string AdminTenantId int DigitalOceanAPIKey string DigitalOceanRegion string DigitalOceanImage string DigitalOceanSSHAuthorizedKeys []ConfigSSHKey GandiAPIKey string SSHPrivateKeyFile string BackblazeBucketName string BackblazeKeyId string BackblazeSecretKey string ThresholdPort int ThresholdManagementPort int DatabaseConnectionString string DatabaseType string DatabaseSchema string SMTP EmailService } type ConfigSSHKey struct { Name string PublicKey string } const isProduction = false func main() { _, err := time.LoadLocation("UTC") if err != nil { panic(errors.Wrap(err, "can't start the app because can't load UTC location")) } workingDirectory := determineWorkingDirectoryByLocatingConfigFile() config := getConfig(workingDirectory) model := initDatabase(config) emailService := &config.SMTP err = emailService.Initialize() if err != nil { panic(err) } easypkiInstance := NewGreenhouseEasyPKI(model) pkiService := pki.NewPKIService(easypkiInstance) ingressService := NewIngressService(config, model) backendApp := initBackend(workingDirectory, config, pkiService, model, emailService) frontendApp := initFrontend(workingDirectory, config, model, backendApp, emailService, ingressService) scheduledTasks := NewScheduledTasks(ingressService, backendApp, model) err = scheduledTasks.Initialize() if err != nil { // TODO should this be Fatalf?? log.Printf("Greenhouse's initialization process failed: \n%+v\n\n", err) } go (func(backendApp *BackendApp) { defer (func() { if r := recover(); r != nil { fmt.Printf("backendApp: panic: %+v\n", r) debug.PrintStack() } })() for { err := backendApp.ConsumeMetrics() if err != nil { log.Printf("metric collection failed: %+v\n", err) } time.Sleep(time.Second * 6) } })(backendApp) AddAPIRoutesToFrontend(&frontendApp) // TODO disable this for prod if !isProduction { go (func() { for { time.Sleep(time.Second) frontendApp.reloadTemplates() } })() // go (func() { // var appUrl = fmt.Sprintf("http://localhost:%d", config.FrontendPort) // var serverIsRunning = false // var attempts = 0 // for !serverIsRunning && attempts < 15 { // attempts++ // time.Sleep(time.Millisecond * 500) // client := &http.Client{ // Timeout: time.Millisecond * 500, // } // response, err := client.Get(appUrl) // if err == nil && response.StatusCode == 200 { // serverIsRunning = true // } // } // openUrl(appUrl) // })() } err = frontendApp.ListenAndServe() panic(err) } func getConfig(workingDirectory string) *Config { configBytes, err := ioutil.ReadFile(filepath.Join(workingDirectory, "config.json")) if err != nil { log.Fatalf("getConfig(): can't ioutil.ReadFile(\"config.json\") because %+v \n", err) } var config Config err = json.Unmarshal(configBytes, &config) if err != nil { log.Fatalf("runServer(): can't json.Unmarshal(configBytes, &config) because %+v \n", err) } if config.AdminTenantId == 0 { config.AdminTenantId = 1 } configToLog, _ := json.MarshalIndent(config, "", " ") configToLogString := string(configToLog) configToLogString = regexp.MustCompile( `("DigitalOceanAPIKey": "[^"]{2})[^"]+([^"]{2}",)`, ).ReplaceAllString( configToLogString, "$1******$2", ) configToLogString = regexp.MustCompile( `("DatabaseConnectionString": "[^"]+ password=)[^" ]+( [^"]+",)`, ).ReplaceAllString( configToLogString, "$1******$2", ) configToLogString = regexp.MustCompile( `("Password": ")[^"]+(",)`, ).ReplaceAllString( configToLogString, "$1******$2", ) configToLogString = regexp.MustCompile( `("GandiAPIKey": ")[^"]+(",)`, ).ReplaceAllString( configToLogString, "$1******$2", ) configToLogString = regexp.MustCompile( `("BackblazeSecretKey": ")[^"]+(",)`, ).ReplaceAllString( configToLogString, "$1******$2", ) log.Printf("🌱🏠 greenhouse is starting up using config:\n%s\n", configToLogString) return &config } func determineWorkingDirectoryByLocatingConfigFile() string { workingDirectory, err := os.Getwd() if err != nil { log.Fatalf("determineWorkingDirectoryByLocatingConfigFile(): can't os.Getwd(): %+v", err) } executableDirectory, err := getCurrentExecDir() if err != nil { log.Fatalf("determineWorkingDirectoryByLocatingConfigFile(): can't getCurrentExecDir(): %+v", err) } configFileLocation1 := filepath.Join(executableDirectory, "config.json") configFileLocation2 := filepath.Join(workingDirectory, "config.json") configFileLocation := configFileLocation1 configFileStat, err := os.Stat(configFileLocation) workingDirectoryToReturn := executableDirectory if err != nil || !configFileStat.Mode().IsRegular() { configFileLocation = configFileLocation2 configFileStat, err = os.Stat(configFileLocation) workingDirectoryToReturn = workingDirectory } if err != nil || !configFileStat.Mode().IsRegular() { log.Fatalf("determineWorkingDirectoryByLocatingConfigFile(): no config file. checked %s and %s", configFileLocation1, configFileLocation2) } return workingDirectoryToReturn } func getCurrentExecDir() (dir string, err error) { path, err := exec.LookPath(os.Args[0]) if err != nil { fmt.Printf("exec.LookPath(%s) returned %s\n", os.Args[0], err) return "", err } absPath, err := filepath.Abs(path) if err != nil { fmt.Printf("filepath.Abs(%s) returned %s\n", path, err) return "", err } dir = filepath.Dir(absPath) return dir, nil } func openUrl(url string) { var err error switch runtime.GOOS { case "linux": err = exec.Command("xdg-open", url).Start() case "darwin": err = exec.Command("open", url).Start() case "windows": err = exec.Command("rundll32", "url.dll,FileProtocolHandler", url).Start() default: err = fmt.Errorf("unsupported platform") } if err != nil { fmt.Printf("can't open app in web browser because '%s'\n", err) } }
|
__label__pos
| 0.998463 |
Switch To MySQL Tutorial
A very common step that users may want to do is switch away from the bundled HSQL database to a more mature database such as MySQL. We have a general guide on using MySQL, but this tutorial will be more explicit specifically regarding Heat Clinic.
1. Download and install MySQL Database (http://dev.mysql.com/downloads/mysql/)
2. Create a new database and a user capable of accessing this database with privileges for creating tables included (see MySQL documentation if you have questions about how to administrate databases and users).
3. Update your pom.xml files to reference MySQL connectors. In the root pom.xml, you want to place the following in the <dependencyManagement> section:
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.26</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
and you'll want to place the following in the <dependencies> section of admin/pom.xml and site/pom.xml:
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>
4. Change the JNDI resource in jetty-env.xml to match your MySQL installation. For example, it might look like this:
<New id="webDS" class="org.eclipse.jetty.plus.jndi.Resource">
<Arg>jdbc/web</Arg>
<Arg>
<New class="org.apache.commons.dbcp.BasicDataSource">
<Set name="driverClassName">com.mysql.jdbc.Driver</Set>
<Set name="url">jdbc:mysql://localhost:3306/broadleaf?useUnicode=true&characterEncoding=utf8</Set>
<Set name="username">root</Set>
<Set name="password"></Set>
</New>
</Arg>
</New>
<New id="webSecureDS" class="org.eclipse.jetty.plus.jndi.Resource">
<Arg>jdbc/secure</Arg>
<Arg>
<New class="org.apache.commons.dbcp.BasicDataSource">
<Set name="driverClassName">com.mysql.jdbc.Driver</Set>
<Set name="url">jdbc:mysql://localhost:3306/broadleaf?useUnicode=true&characterEncoding=utf8</Set>
<Set name="username">root</Set>
<Set name="password"></Set>
</New>
</Arg>
</New>
<New id="webStorageDS" class="org.eclipse.jetty.plus.jndi.Resource">
<Arg>jdbc/storage</Arg>
<Arg>
<New class="org.apache.commons.dbcp.BasicDataSource">
<Set name="driverClassName">com.mysql.jdbc.Driver</Set>
<Set name="url">jdbc:mysql://localhost:3306/broadleaf?useUnicode=true&characterEncoding=utf8</Set>
<Set name="username">root</Set>
<Set name="password"></Set>
</New>
</Arg>
</New>
Note: You must change jetty-env.xml in both the site and the admin projects.
5. Update the runtime properties to use the correct MySQL dialect. In core/src/main/resources/runtime-properties/common-shared.properties, you will want to update the three persistence unit dialects to say:
blPU.hibernate.dialect=org.hibernate.dialect.MySQL5InnoDBDialect
blSecurePU.hibernate.dialect=org.hibernate.dialect.MySQL5InnoDBDialect
blCMSStorage.hibernate.dialect=org.hibernate.dialect.MySQL5InnoDBDialect
6. Update the build properties to use the correct MySQL dialect. In build.properties, you will want to update the following:
ant.hibernate.sql.ddl.dialect=org.hibernate.dialect.MySQL5InnoDBDialect
...
ant.blPU.url=jdbc:mysql://localhost:3306/broadleaf
ant.blPU.userName=root
ant.blPU.password=
ant.blPU.driverClassName=com.mysql.jdbc.Driver
ant.blSecurePU.url=jdbc:mysql://localhost:3306/broadleaf
ant.blSecurePU.userName=root
ant.blSecurePU.password=
ant.blSecurePU.driverClassName=com.mysql.jdbc.Driver
ant.blCMSStorage.url=jdbc:mysql://localhost:3306/broadleaf
ant.blCMSStorage.userName=root
ant.blCMSStorage.password=
And that's it! You should now be up and running with MySQL.
|
__label__pos
| 0.646071 |
.editorconfig000066400000000000000000000006401433113561400135340ustar00rootroot00000000000000# EditorConfig helps developers define and maintain consistent # coding styles between different editors and IDEs # editorconfig.org root = true [*] # Change these settings to your own preference indent_style = space indent_size = 4 # We recommend you to keep these unchanged end_of_line = lf charset = utf-8 trim_trailing_whitespace = false insert_final_newline = true [*.md] trim_trailing_whitespace = false .github/000077500000000000000000000000001433113561400124175ustar00rootroot00000000000000.github/workflows/000077500000000000000000000000001433113561400144545ustar00rootroot00000000000000.github/workflows/build.yml000066400000000000000000000016761433113561400163100ustar00rootroot00000000000000# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node # For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions name: build on: schedule: - cron: '0 0 1 * *' push: branches: [ master ] pull_request: branches: [ master ] jobs: build: runs-on: ubuntu-latest strategy: matrix: node-version: ['lts/*'] # See supported Node.js release schedule at https://nodejs.org/en/about/releases/ steps: - uses: actions/checkout@v2 - name: Use Node.js ${{ matrix.node-version }} uses: actions/setup-node@v2 with: node-version: ${{ matrix.node-version }} - run: npm i -g grunt-cli - run: npm install - run: grunt .gitignore000066400000000000000000000003511433113561400130460ustar00rootroot00000000000000/build /node_modules /*.log /*.iws .idea/workspace.xml .idea/tasks.xml .idea/profiles_settings.xml .idea/inspectionProfiles/Project_Default.xml .idea/inspectionProfiles/profiles_settings.xml node_modules/.yarn-integrity .nyc_output .npmignore000066400000000000000000000002611433113561400130550ustar00rootroot00000000000000/.idea /artifacts /build /Gemfile /_layouts /_site /_includes /test /node_modules /*.iml /*.ipr /*.iws /.travis.yml /.scrutinizer.yml /Gruntfile.js /corifeus-boot.json /.github .travis.yml000066400000000000000000000014551433113561400131750ustar00rootroot00000000000000language: node_js cache: npm: false node_js: - lts/* before_script: - npm install -g grunt-cli npm env: global: secure: KZ0VSEvR4z9sxJU8RNdWc/1E8yotxrWYOVXkcH7cBtbodW5fRlva5K9DZKJzUf55umzF/zCzudWU740EAkUm4ciFYzEWPbpU4eHLJGInu4fo8zmfyKcJY6AJE4XpjPEs7pJfZyHik2R0ycWggV+Hn0lwXRhobicXRPCsDhLfnFkHIyzCGYQEMzmOzYB0MXvVxlvgxdyZvSbX6tfh6WRBe7KQLEBE6GzBYsXLDyRujyxHtcMOwqT4YVTNI/KEJXxdR7OBxvNKnyLZ68h6uWIPPnV6hfoBKnxKiAbZC+epL0zmpvMMOZoW49+mV1o/OX3sCbmHvGmH6sefV4sslBHEVlh+ARZfFZHfL60XIzbwHzzlfviKwnzrwBjaUTJiTXfl8xm/Z1TwujsIfDeObj1u26vq2aG2UDAqzjSlr8O3NPRV2ApNgK4C4wXrPLtAp8HAkG6U7fG5qdnLFgQCcbj07VMxSZVCcM4ULpeqGnlL1vBS25Qe/Ntpt7DGC/6PA2ucLU9V4FszaNgn2fQ9fyKa6z1v8fOuq2Lpes4lUx1LYR06Vu4yca3yEIEsT7jry3MfKNiuFP/KbgTgV8cU+dLbIrJRlu6D5vslzNSExGAHXCCZv6BfJXXa/nyff6NhczpD2hhNZRdojWX01AGKWNi+5K+mPoU78O58N/gZ+4cpv2Q= Gruntfile.js000066400000000000000000000005261433113561400133570ustar00rootroot00000000000000const utils = require('corifeus-utils'); module.exports = (grunt) => { const builder = require(`corifeus-builder`); const loader = new builder.loader(grunt); loader.js({ replacer: { type: 'p3x', npmio: true, }, }); grunt.registerTask('default', builder.config.task.build.js); } LICENSE000066400000000000000000000023561433113561400120720ustar00rootroot00000000000000 @license p3x-binary-search-closest v2022.4.111 🚅 Find the closest or exact value using binary search https://corifeus.com/binary-search-closest Copyright (c) 2022 Patrik Laszlo / P3X / Corifeus and contributors. MIT License Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. README.md000066400000000000000000000230101433113561400123320ustar00rootroot00000000000000[//]: #@corifeus-header [](https://www.npmjs.com/package/p3x-binary-search-closest/) [](https://paypal.me/patrikx3) [](https://www.patrikx3.com/en/front/contact) [](https://www.facebook.com/corifeus.software) [](https://github.com/patrikx3/binary-search-closest/actions?query=workflow%3Abuild) [](https://stats.uptimerobot.com/9ggnzcWrw) # 🚅 Find the closest or exact value using binary search v2022.4.111 **Bugs are evident™ - MATRIX️** ### NodeJS LTS is supported ### Built on NodeJs version ```txt v16.14.0 ``` # Description [//]: #@corifeus-header:end Before, you want to find the closest or exact value in an array of objects or an array by values, it is important, so that you sort in ascending order, otherwise, it will not work. Example below shows how it works. The search algorithm is based on https://www.geeksforgeeks.org/find-closest-number-array/. If you have a big array, you can use a worker thread as in the code is on the bottom (4 ways to do it / same as in the event loop, but without blocking the event loop.) # Installation #### For NodeJs ```bash npm install p3x-binary-search-closest ``` # Usage If you have mocha, you can test like this, it has a few use cases (you can see, before I execute this micro-service, I sort the array): **Note:** Given npmjs.com has a narrow page, it is better to see the code on https://corifeus.com/binary-search-closest or https://github.com/patrikx3/binary-search-closest Of course, when using a worker thread, the execution is about 20-25ms longer, than when we are in the event loop, so the worker thread is valid when we are working on a big dataset. ```js const assert = require('assert'); // for only browser (remove worker thread as is NodeJs Specific) const bsClosest = require('p3x-binary-search-closest/browser') // for full blown functions const bsClosest = require('p3x-binary-search-closest') describe('binary search closest', () => { it('binary search closest by array value, when it is exact match', () => { const arr = [6, 9, 8, 4, 1, 7, 3, 10, 5, 2] arr.sort() const foundValue = bsClosest.byValue(arr, 5) assert.ok(foundValue === 5) }) it('binary search closest by array value, when it is not existing, but find the closest value', () => { const arr = [9, 8, 4, 1, 7, 3, 10, 5, 2] arr.sort() const foundValue = bsClosest.byValue(arr, 6) assert.ok(foundValue === 7) }) it('binary search closest by array with a property, when it is exact match', () => { const arr = [ { id: 4538765, value: 9 }, { id: 4535675, value: 10 }, { id: 4535, value: 1 }, { id: 45654645, value: 3 }, { id: 123123123, value: 2 }, { id: 4532345, value: 4 }, { id: 4545335, value: 7 }, { id: 124535, value: 6 }, { id: 4587635, value: 8 }, ] arr.sort((a, b) => (a.value > b.value) ? 1 : -1) const foundValue = bsClosest.byProperty(arr, 7, 'value') assert.ok(foundValue.value === 7) }) it('binary search closest by array with a property, but find the closest value', () => { const arr = [ { id: 4538765, value: 9 }, { id: 4535675, value: 10 }, { id: 4535, value: 1 }, { id: 45654645, value: 3 }, { id: 123123123, value: 2 }, { id: 4532345, value: 4 }, { id: 4545335, value: 7 }, { id: 124535, value: 6 }, { id: 4587635, value: 8 }, ] arr.sort((a, b) => (a.value > b.value) ? 1 : -1) const foundValue = bsClosest.byProperty(arr, 5, 'value') assert.ok(foundValue.value === 6) }) it('using thread worker, binary search closest by array value, when it is exact match', async() => { const arr = [6, 9, 8, 4, 1, 7, 3, 10, 5, 2] arr.sort() const foundValue = await bsClosest.worker({ type: 'value', target: 5, array: arr, }) assert.ok(foundValue === 5) }) it('using thread worker, binary search closest by array value, but find the closest value', async() => { const arr = [9, 8, 4, 1, 7, 3, 10, 5, 2] arr.sort() const foundValue = await bsClosest.worker({ type: 'value', target: -1, array: arr, }) assert.ok(foundValue === 1) }) it('using thread worker, binary search closest by array with a property, when it is exact match', async() => { const arr = [ { id: 4538765, value: 9 }, { id: 4535675, value: 10 }, { id: 4535, value: 1 }, { id: 45654645, value: 3 }, { id: 123123123, value: 2 }, { id: 4532345, value: 4 }, { id: 4545335, value: 7 }, { id: 124535, value: 6 }, { id: 4587635, value: 8 }, ] arr.sort((a, b) => (a.value > b.value) ? 1 : -1) const foundValue = await bsClosest.worker({ type: 'property', target: 7, array: arr, property: 'value', }) assert.ok(foundValue.value === 7) }) it('using thread worker, binary search closest by array with a property, but find the closest value', async() => { const arr = [ { id: 4538765, value: 9 }, { id: 4535675, value: 10 }, { id: 4535, value: 1 }, { id: 45654645, value: 3 }, { id: 123123123, value: 2 }, { id: 4532345, value: 4 }, { id: 4545335, value: 7 }, { id: 124535, value: 6 }, { id: 4587635, value: 8 }, ] arr.sort((a, b) => (a.value > b.value) ? 1 : -1) const foundValue = await bsClosest.worker({ type: 'property', target: 5, array: arr, property: 'value', }) assert.ok(foundValue.value === 6) }) }) ``` [//]: #@corifeus-footer --- 🙏 This is an open-source project. Star this repository, if you like it, or even donate to maintain the servers and the development. Thank you so much! Possible, this server, rarely, is down, please, hang on for 15-30 minutes and the server will be back up. All my domains ([patrikx3.com](https://patrikx3.com) and [corifeus.com](https://corifeus.com)) could have minor errors, since I am developing in my free time. However, it is usually stable. **Note about versioning:** Versions are cut in Major.Minor.Patch schema. Major is always the current year. Minor is either 4 (January - June) or 10 (July - December). Patch is incremental by every build. If there is a breaking change, it should be noted in the readme. --- [**P3X-BINARY-SEARCH-CLOSEST**](https://corifeus.com/binary-search-closest) Build v2022.4.111 [](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=QZVM4V6HVZJW6) [](https://www.patrikx3.com/en/front/contact) [](https://www.facebook.com/corifeus.software) ## P3X Sponsor [IntelliJ - The most intelligent Java IDE](https://www.jetbrains.com/?from=patrikx3) [](https://www.jetbrains.com/?from=patrikx3) [//]: #@corifeus-footer:end binary-search-closest.iml000066400000000000000000000005171433113561400157660ustar00rootroot00000000000000 browser.js000066400000000000000000000002151433113561400130760ustar00rootroot00000000000000const util = require('./src/util') module.exports = { byProperty: util.binarySearchByProperty, byValue: util.binarySearchByValue, } package.json000066400000000000000000000022561433113561400133520ustar00rootroot00000000000000{ "name": "p3x-binary-search-closest", "version": "2022.4.111", "corifeus": { "icon": "fas fa-train", "prefix": "p3x-", "publish": true, "type": "p3x", "code": "Bullet", "nodejs": "v16.14.0", "opencollective": false, "reponame": "binary-search-closest", "build": true }, "description": "🚅 Find the closest or exact value using binary search", "main": "src/index.js", "scripts": { "test": "grunt && mocha ./test/mocha/*.js" }, "repository": { "type": "git", "url": "git+https://github.com/patrikx3/binary-search-closest.git" }, "keywords": [ "search", "binary-search", "binary", "value", "object", "property", "closest", "exact" ], "author": "Patrik Laszlo ", "license": "MIT", "bugs": { "url": "https://github.com/patrikx3/binary-search-closest/issues" }, "homepage": "https://corifeus.com/binary-search-closest", "devDependencies": { "corifeus-builder": "^2022.4.111" }, "engines": { "node": ">=12.13.0" } }src/000077500000000000000000000000001433113561400116465ustar00rootroot00000000000000src/index.js000066400000000000000000000003241433113561400133120ustar00rootroot00000000000000const util = require('./util') const utilWorker = require('./util.worker') module.exports = { byProperty: util.binarySearchByProperty, byValue: util.binarySearchByValue, worker: utilWorker.worker, } src/util.js000066400000000000000000000056121433113561400131650ustar00rootroot00000000000000 const binarySearchByProperty = (obj, target, property) => { const n = obj.length // Corner cases if (target <= obj[0][property]) { return obj[0]; } if (target >= obj[n - 1][property]) { return obj[n - 1]; } // Doing binary search let i = 0, j = n, mid = 0; while (i < j) { mid = Math.floor((i + j) / 2) if (obj[mid][property] == target) { return obj[mid]; } /* If target is less than array element, then search in left */ if (target < obj[mid][property]) { // If target is greater than previous // to mid, return closest of two if (mid > 0 && target > obj[mid - 1][property]) { return binarySearchByPropertyGetClosest(obj[mid - 1], obj[mid], target, property); } /* Repeat for left half */ j = mid; } else { // If target is greater than mid if (mid < n - 1 && target < obj[mid + 1][property]) { return binarySearchByPropertyGetClosest(obj[mid], obj[mid + 1], target, property); } // update i i = mid + 1; } } // Only single element left after search return obj[mid]; } const binarySearchByPropertyGetClosest = (val1, val2, target, property) => { if (target - val1[property] >= val2[property] - target) { return val2; } else { return val1; } } const binarySearchByValue = (obj, target) => { const n = obj.length // Corner cases if (target <= obj[0]) { return obj[0]; } if (target >= obj[n - 1]) { return obj[n - 1]; } // Doing binary search let i = 0, j = n, mid = 0; while (i < j) { mid = Math.floor((i + j) / 2) if (obj[mid] == target) { return obj[mid]; } /* If target is less than array element, then search in left */ if (target < obj[mid]) { // If target is greater than previous // to mid, return closest of two if (mid > 0 && target > obj[mid - 1]) { return binarySearchByValueGetClosest(obj[mid - 1], obj[mid], target); } /* Repeat for left half */ j = mid; } else { // If target is greater than mid if (mid < n - 1 && target < obj[mid + 1]) { return binarySearchByValueGetClosest(obj[mid], obj[mid + 1], target); } // update i i = mid + 1; } } // Only single element left after search return obj[mid]; } const binarySearchByValueGetClosest = (val1, val2, target) => { if (target - val1 >= val2 - target) { return val2; } else { return val1; } } module.exports.binarySearchByProperty = binarySearchByProperty module.exports.binarySearchByValue = binarySearchByValue src/util.worker.js000066400000000000000000000011311433113561400144650ustar00rootroot00000000000000const worker = async (options) => { const { Worker } = require('worker_threads'); const workerResult = await new Promise((resolve, reject) => { const worker = new Worker(`${__dirname}/worker.js`, { workerData: options }); worker.on('message', resolve); worker.on('error', reject); worker.on('exit', (code) => { if (code !== 0) { reject(new Error(`Worker stopped with exit code ${code}`)); } worker.terminate() }); }); return workerResult }; module.exports.worker = worker src/worker.js000066400000000000000000000016211433113561400135150ustar00rootroot00000000000000const { parentPort, workerData } = require('worker_threads'); const util = require('./util'); const allowedTypes = ['value', 'property'] let type = workerData.type const array = workerData.array const target = workerData.target const property = workerData.property if (type === undefined) { type = allowedTypes[0] } if (!allowedTypes.includes(type)) { throw new Error(`The allowed types are ${allowedTypes.join(', ')}, you tried ${type}`) } if (type === 'property' && (typeof property !== 'string' || property.length < 1)) { throw new Error(`You tried by searching by binarySearchByProperty, but you forgot the property options, which has to be a string and at least one character`) } let foundValue if (type === 'value') { foundValue = util.binarySearchByValue(array, target) } else { foundValue = util.binarySearchByProperty(array, target, property) } parentPort.postMessage(foundValue) test/000077500000000000000000000000001433113561400120365ustar00rootroot00000000000000test/mocha/000077500000000000000000000000001433113561400131255ustar00rootroot00000000000000test/mocha/test.js000066400000000000000000000132401433113561400144420ustar00rootroot00000000000000const assert = require('assert'); const bsClosest = require('../../src') describe('binary search closest', () => { it('binary search closest by array value, when it is exact match', () => { const arr = [6, 9, 8, 4, 1, 7, 3, 10, 5, 2] arr.sort() const foundValue = bsClosest.byValue(arr, 5) assert.ok(foundValue === 5) }) it('binary search closest by array value, when it is not existing, but find the closest value', () => { const arr = [9, 8, 4, 1, 7, 3, 10, 5, 2] arr.sort() const foundValue = bsClosest.byValue(arr, 6) assert.ok(foundValue === 7) }) it('binary search closest by array with a property, when it is exact match', () => { const arr = [ { id: 4538765, value: 9 }, { id: 4535675, value: 10 }, { id: 4535, value: 1 }, { id: 45654645, value: 3 }, { id: 123123123, value: 2 }, { id: 4532345, value: 4 }, { id: 4545335, value: 7 }, { id: 124535, value: 6 }, { id: 4587635, value: 8 }, ] arr.sort((a, b) => (a.value > b.value) ? 1 : -1) const foundValue = bsClosest.byProperty(arr, 7, 'value') assert.ok(foundValue.value === 7) }) it('binary search closest by array with a property, but find the closest value', () => { const arr = [ { id: 4538765, value: 9 }, { id: 4535675, value: 10 }, { id: 4535, value: 1 }, { id: 45654645, value: 3 }, { id: 123123123, value: 2 }, { id: 4532345, value: 4 }, { id: 4545335, value: 7 }, { id: 124535, value: 6 }, { id: 4587635, value: 8 }, ] arr.sort((a, b) => (a.value > b.value) ? 1 : -1) const foundValue = bsClosest.byProperty(arr, 5, 'value') assert.ok(foundValue.value === 6) }) it('using thread worker, binary search closest by array value, when it is exact match', async() => { const arr = [6, 9, 8, 4, 1, 7, 3, 10, 5, 2] arr.sort() const foundValue = await bsClosest.worker({ type: 'value', target: 5, array: arr, }) assert.ok(foundValue === 5) }) it('using thread worker, binary search closest by array value, but find the closest value', async() => { const arr = [9, 8, 4, 1, 7, 3, 10, 5, 2] arr.sort() const foundValue = await bsClosest.worker({ type: 'value', target: -1, array: arr, }) assert.ok(foundValue === 1) }) it('using thread worker, binary search closest by array with a property, when it is exact match', async() => { const arr = [ { id: 4538765, value: 9 }, { id: 4535675, value: 10 }, { id: 4535, value: 1 }, { id: 45654645, value: 3 }, { id: 123123123, value: 2 }, { id: 4532345, value: 4 }, { id: 4545335, value: 7 }, { id: 124535, value: 6 }, { id: 4587635, value: 8 }, ] arr.sort((a, b) => (a.value > b.value) ? 1 : -1) const foundValue = await bsClosest.worker({ type: 'property', target: 7, array: arr, property: 'value', }) assert.ok(foundValue.value === 7) }) it('using thread worker, binary search closest by array with a property, but find the closest value', async() => { const arr = [ { id: 4538765, value: 9 }, { id: 4535675, value: 10 }, { id: 4535, value: 1 }, { id: 45654645, value: 3 }, { id: 123123123, value: 2 }, { id: 4532345, value: 4 }, { id: 4545335, value: 7 }, { id: 124535, value: 6 }, { id: 4587635, value: 8 }, ] arr.sort((a, b) => (a.value > b.value) ? 1 : -1) const foundValue = await bsClosest.worker({ type: 'property', target: 5, array: arr, property: 'value', }) assert.ok(foundValue.value === 6) }) })
|
__label__pos
| 0.745212 |
I discovered some time based user enumeration in the wild with some pretty nice implications, so let’s discuss them.
So firstly, what is time based user enumeration or tbue as I will refer to it for the rest of this post?
Essentially tbue occurs in sites which do not return constant time responses regardless of if an account exists or not. You can think of it roughly speaking as the following code block:
import asyncio
valid_logins = {"admin": "admin123"}
@app.post("/login")
async def login(username: str, password: str):
if username not in valid_logins:
return JSONResponse(content={"message": "Invalid authentication"}, status_code=400)
# Imagine this is an expensive password comparison
if password == valid_logins[username]:
await asyncio.sleep(0.25) # To mock an expensive hash & comparison
return JSONResponse(content={"message": "Success"}, status_code=200)
return JSONResponse(content={"message": "Invalid authentication"}, status_code=400)
And while this doesn’t leak if a user is valid or not based on the username or password combination we can see that by timing the requests we should see two peaks. One peak for invalid users and a second peak for valid users, this is the basis for time based user enumeration.
Setup Link to heading
For the purposes of demonstration I have set up a basic web server tbue.skelmis.co.nz with a couple login routes that showcase various enumeration behaviour.
To aid in demonstration all requests (server) execution time are timed under the x-time-ms header as seen below. Further, the RTT for requests is not considered as a part of this demonstration and is considered equal regardless.
@app.middleware("http")
async def timer_injection(request: Request, call_next):
start = time.time()
response: Response = await call_next(request)
finish = time.time()
response.headers["X-TIME-MS"] = str((finish - start) * 1000)
return response
The code running the website can be found here, for the exploitation step we are specifically focused on this route/function.
Exploiting Link to heading
Requests shall be made and data tracked via the Python script below:
import asyncio
import json
import httpx
# 25 requests per second limiter
# It's not about overloading the server after all
semaphore = asyncio.Semaphore(25)
data: dict[str, float] = {}
async def request(ac: httpx.AsyncClient, username: str):
async with semaphore:
resp = await ac.post(
"https://tbue.skelmis.co.nz/login/2",
data={
"username": username,
"password": "ThisDoesntMatterHere",
},
)
resp_time = float(resp.headers["X-TIME-MS"])
data[username] = resp_time
async def main():
async with httpx.AsyncClient() as client:
with open("burp_user_names.txt", "r") as in_file:
coros = [request(client, uname.rstrip("\n")) for uname in in_file.readlines()]
await asyncio.wait(coros)
with open("overall_request_data.json", "w") as out_file:
out_file.write(json.dumps(data))
print("Finished")
asyncio.run(main())
Analysis Link to heading
After we run this, we now have a file containing all the raw data required to generate a graph containing login times. To simplify the process, the following script was used:
import json
import matplotlib.pyplot as plt
import seaborn as sns
sns.set(style="darkgrid")
def read_out(file):
data_out = []
with open(file) as in_file:
raw_data = json.loads(in_file.read())
for username, time in raw_data.items():
data_out.append((username, time))
return data_out
data_raw = read_out("overall_request_data.json")
ax = sns.histplot(
{"Possible users": [entry[1] for entry in data_raw]},
stat="percent",
)
ax.set_xlabel("Response time (MS)")
plt.savefig("./without_creds.png")
plt.show()
Which produces the following graph:
Initial graph of times
When looking at the graph we can see decent indications of two groups around the 75ms mark. This indicates to us that requests that take longer then say 75ms, are likely going to be valid users on the platform we are testing.
To test this hypothesis, lets create a graph with valid and invalid users highlighted separately.
Graph with creds
As we can see there is overlap between valid and invalid users, this is one of the downsides to this approach for enumeration. While we can make best guesses based off of the data available to us, we can only say that a user is likely to be valid on the platform. However, when standard user enumeration vectors fail time based enumeration I always at-least try time based because at the end of the day I’d rather have some measure of valid accounts compared to none.
If you wish to find all the scripts used throughout this post as well as some extras I didn’t discuss, take a look at the GitHub repo here.
|
__label__pos
| 0.790355 |
Commit 30f481c2 by Robbert
Merge branch 'stdpp_scope' into 'master'
Use `stdpp_scope` for all notations. See merge request !17
parents c92654ed 4b73a5c1
Pipeline #5280 passed with stages
in 14 minutes 25 seconds
......@@ -92,10 +92,10 @@ Definition map_included `{∀ A, Lookup K A (M A)} {A}
(R : relation A) : relation (M A) := map_relation R (λ _, False) (λ _, True).
Definition map_disjoint `{ A, Lookup K A (M A)} {A} : relation (M A) :=
map_relation (λ _ _, False) (λ _, True) (λ _, True).
Infix "##ₘ" := map_disjoint (at level 70) : C_scope.
Infix "##ₘ" := map_disjoint (at level 70) : stdpp_scope.
Hint Extern 0 (_ ## _) => symmetry; eassumption.
Notation "( m ##ₘ.)" := (map_disjoint m) (only parsing) : C_scope.
Notation "(.##ₘ m )" := (λ m2, m2 ## m) (only parsing) : C_scope.
Notation "( m ##ₘ.)" := (map_disjoint m) (only parsing) : stdpp_scope.
Notation "(.##ₘ m )" := (λ m2, m2 ## m) (only parsing) : stdpp_scope.
Instance map_subseteq `{ A, Lookup K A (M A)} {A} : SubsetEq (M A) :=
map_included (=).
......
......@@ -30,21 +30,21 @@ Arguments Permutation {_} _ _ : assert.
Arguments Forall_cons {_} _ _ _ _ _ : assert.
Remove Hints Permutation_cons : typeclass_instances.
Notation "(::)" := cons (only parsing) : C_scope.
Notation "( x ::)" := (cons x) (only parsing) : C_scope.
Notation "(:: l )" := (λ x, cons x l) (only parsing) : C_scope.
Notation "(++)" := app (only parsing) : C_scope.
Notation "( l ++)" := (app l) (only parsing) : C_scope.
Notation "(++ k )" := (λ l, app l k) (only parsing) : C_scope.
Infix "≡ₚ" := Permutation (at level 70, no associativity) : C_scope.
Notation "(≡ₚ)" := Permutation (only parsing) : C_scope.
Notation "( x ≡ₚ)" := (Permutation x) (only parsing) : C_scope.
Notation "(≡ₚ x )" := (λ y, y ≡ₚ x) (only parsing) : C_scope.
Notation "(≢ₚ)" := (λ x y, ¬x ≡ₚ y) (only parsing) : C_scope.
Notation "x ≢ₚ y":= (¬x ≡ₚ y) (at level 70, no associativity) : C_scope.
Notation "( x ≢ₚ)" := (λ y, x ≢ₚ y) (only parsing) : C_scope.
Notation "(≢ₚ x )" := (λ y, y ≢ₚ x) (only parsing) : C_scope.
Notation "(::)" := cons (only parsing) : stdpp_scope.
Notation "( x ::)" := (cons x) (only parsing) : stdpp_scope.
Notation "(:: l )" := (λ x, cons x l) (only parsing) : stdpp_scope.
Notation "(++)" := app (only parsing) : stdpp_scope.
Notation "( l ++)" := (app l) (only parsing) : stdpp_scope.
Notation "(++ k )" := (λ l, app l k) (only parsing) : stdpp_scope.
Infix "≡ₚ" := Permutation (at level 70, no associativity) : stdpp_scope.
Notation "(≡ₚ)" := Permutation (only parsing) : stdpp_scope.
Notation "( x ≡ₚ)" := (Permutation x) (only parsing) : stdpp_scope.
Notation "(≡ₚ x )" := (λ y, y ≡ₚ x) (only parsing) : stdpp_scope.
Notation "(≢ₚ)" := (λ x y, ¬x ≡ₚ y) (only parsing) : stdpp_scope.
Notation "x ≢ₚ y":= (¬x ≡ₚ y) (at level 70, no associativity) : stdpp_scope.
Notation "( x ≢ₚ)" := (λ y, x ≢ₚ y) (only parsing) : stdpp_scope.
Notation "(≢ₚ x )" := (λ y, y ≢ₚ x) (only parsing) : stdpp_scope.
Instance maybe_cons {A} : Maybe2 (@cons A) := λ l,
match l with x :: l => Some (x,l) | _ => None end.
......@@ -240,8 +240,8 @@ Fixpoint permutations {A} (l : list A) : list (list A) :=
The predicate [prefix] holds if the first list is a prefix of the second. *)
Definition suffix {A} : relation (list A) := λ l1 l2, k, l2 = k ++ l1.
Definition prefix {A} : relation (list A) := λ l1 l2, k, l2 = l1 ++ k.
Infix "`suffix_of`" := suffix (at level 70) : C_scope.
Infix "`prefix_of`" := prefix (at level 70) : C_scope.
Infix "`suffix_of`" := suffix (at level 70) : stdpp_scope.
Infix "`prefix_of`" := prefix (at level 70) : stdpp_scope.
Hint Extern 0 (_ `prefix_of` _) => reflexivity.
Hint Extern 0 (_ `suffix_of` _) => reflexivity.
......@@ -271,7 +271,7 @@ Inductive sublist {A} : relation (list A) :=
| sublist_nil : sublist [] []
| sublist_skip x l1 l2 : sublist l1 l2 sublist (x :: l1) (x :: l2)
| sublist_cons x l1 l2 : sublist l1 l2 sublist l1 (x :: l2).
Infix "`sublist_of`" := sublist (at level 70) : C_scope.
Infix "`sublist_of`" := sublist (at level 70) : stdpp_scope.
Hint Extern 0 (_ `sublist_of` _) => reflexivity.
(** A list [l2] submseteq a list [l1] if [l2] is obtained by removing elements
......@@ -282,7 +282,7 @@ Inductive submseteq {A} : relation (list A) :=
| submseteq_swap x y l : submseteq (y :: x :: l) (x :: y :: l)
| submseteq_cons x l1 l2 : submseteq l1 l2 submseteq l1 (x :: l2)
| submseteq_trans l1 l2 l3 : submseteq l1 l2 submseteq l2 l3 submseteq l1 l3.
Infix "⊆+" := submseteq (at level 70) : C_scope.
Infix "⊆+" := submseteq (at level 70) : stdpp_scope.
Hint Extern 0 (_ + _) => reflexivity.
(** Removes [x] from the list [l]. The function returns a [Some] when the
......
......@@ -9,7 +9,7 @@ Add Printing Constructor set.
Arguments mkSet {_} _ : assert.
Arguments set_car {_} _ _ : assert.
Notation "{[ x | P ]}" := (mkSet (λ x, P))
(at level 1, format "{[ x | P ]}") : C_scope.
(at level 1, format "{[ x | P ]}") : stdpp_scope.
Instance set_elem_of {A} : ElemOf A (set A) := λ x X, set_car X x.
......
......@@ -13,7 +13,7 @@ Notation length := List.length.
(** * Fix scopes *)
Open Scope string_scope.
Open Scope list_scope.
Infix "+:+" := String.append (at level 60, right associativity) : C_scope.
Infix "+:+" := String.append (at level 60, right associativity) : stdpp_scope.
Arguments String.append : simpl never.
(** * Decision of equality *)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment
|
__label__pos
| 0.537969 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.